按須要引入:
一、安裝:css
cnpm install element-ui --save
cnpm install babel-plugin-component –-save-dev
cnpm install babel-preset-es2015 --save-dev
二、配置.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"]
}
}
}
三、使用:
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
全局引入:
一、安裝:
cnpm install element-ui --save
二、在入口main.js中添加:
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
三、使用:
this.$Loading