全局引入
1、安装依赖
javascript
npm install view-design --save
2、在main.js中引入
javascript
import ViewUI from 'view-design';
import 'view-design/dist/styles/iview.css';
Vue.use(VueRouter);
Vue.use(ViewUI);
按需引入
1、安装依赖
javascript
npm install babel-plugin-import --save-dev
2、在.babelrc文件中plugins属性中配置
javascript
"plugins": [["import", {
"libraryName": "view-design",
"libraryDirectory": "src/components"
}]]
3、在main.js中引入
javascript
import { Button, Table } from 'view-design';
import 'view-design/dist/styles/iview.css';
Vue.component('Button', Button);
Vue.component('Table', Table);