1. 程式人生 > >vue引入element-ui

vue引入element-ui

安裝 cnp tar ins last nod als dex imp

按需要引入:

1、安裝:

cnpm install element-ui --save cnpm install babel-plugin-component –-save-dev cnpm install babel-preset-es2015 --save-dev 2、配置.babelrc: { "presets": [ ["env", { "modules": false, "targets": { "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] } }], // 新增 ["es2015", { "modules": false }], "stage-2" ], "plugins": [ "transform-vue-jsx", "transform-runtime", // 新增 [ "component", { "libraryName": "element-ui", "styleLibraryName": "theme-chalk" } ] ], "env": { "test": { "presets": ["env", "stage-2"], "plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"] } } } 3、使用: import { Loading } from ‘element-ui‘; import { Carousel, CarouselItem } from ‘element-ui‘; import ‘element-ui/lib/theme-chalk/index.css‘; Vue.component(Carousel.name, Carousel); Vue.component(CarouselItem.name, CarouselItem); 或 Vue.use(Carousel); Vue.use(CarouselItem); 可 Vue.prototype.$loading = Loading; this.$loading 全局引入: 1、安裝: cnpm install element-ui --save 2、在入口main.js中添加: import ElementUI from ‘element-ui‘; import ‘element-ui/lib/theme-chalk/index.css‘; Vue.use(ElementUI); 3、使用: this.$Loading

vue引入element-ui