1.mint-uijavascript
安裝:css
npm install mint-ui --save
使用:vue
main.jsjava
// MintUI組件庫 import MintUI from 'mint-ui' import 'mint-ui/lib/style.css' Vue.use(MintUI)
2.vuxwebpack
安裝:web
npm install vux --save npm install vux-loader --save
使用:npm
vux2必須配合vux-loader
使用, 請在build/webpack.base.conf.js
裏參照以下代碼進行配置:json
build / webpack.base.conf.jsbabel
const vuxLoader = require('vux-loader') const webpackConfig = originalConfig // 原來的 module.exports 代碼賦值給變量 webpackConfig module.exports = vuxLoader.merge(webpackConfig, { plugins: ['vux-ui'] })
實例:webpack.base.conf.jsweex
'use strict' const path = require('path') const utils = require('./utils') const config = require('../config') const vueLoaderConfig = require('./vue-loader.conf') // 添加 vux-loader const vuxLoader = require('vux-loader') function resolve (dir) { return path.join(__dirname, '..', dir) } // 原來的 module.exports 代碼賦值給變量 webpackConfig const webpackConfig = { entry: { app: './src/main.js' }, output: { path: config.build.assetsRoot, filename: '[name].js', publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath }, resolve: { extensions: ['.js', '.vue', '.json'], alias: { 'vue$': 'vue/dist/vue.esm.js', '@': resolve('src'), } }, module: { rules: [ { test: /\.vue$/, loader: 'vue-loader', options: vueLoaderConfig }, { test: /\.js$/, loader: 'babel-loader', include: [resolve('src'), resolve('test')] }, { test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, loader: 'url-loader', options: { limit: 10000, name: utils.assetsPath('img/[name].[hash:7].[ext]') } }, { test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, loader: 'url-loader', options: { limit: 10000, name: utils.assetsPath('media/[name].[hash:7].[ext]') } }, { test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, loader: 'url-loader', options: { limit: 10000, name: utils.assetsPath('fonts/[name].[hash:7].[ext]') } } ] } } // 擴展 module.exports = vuxLoader.merge(webpackConfig, { plugins: ['vux-ui'] })
3.weex-ui
安裝:
npm install weex-ui --save
使用:
爲了避免打包全部的組件,你須要使用 babel-plugin-component 來只引入須要的組件打包。
npm i babel-plugin-component -D
.babelrc
// 增長一個plugins的配置到 .babelrc 中 { "plugins": [ [ "component", { "libraryName": "weex-ui", "libDir": "packages" } ] ] }
修改後:
{ "presets": ["es2015", "stage-0"], "plugins": [ [ "component", { "libraryName": "weex-ui", "libDir": "packages" } ] ] }
.