后台(一)vue+element-ui (按需加载)
vue init webpack 项目名称
npm install axios //先安装!
npm install --save axios vue-axios //然后!
npm install vuex --save //安装vuex
npm i element-ui -S //安装vant,Ui框架,选择性安装
npm install babel-plugin-import -D // 与element-ui是绑定安装关系
配置babelrc文件
{ "presets": [ [ "env", { "modules": false, "targets": { "browsers": [ "> 1%", "last 2 versions", "not ie <= 8" ] } } ], "stage-2" ], "plugins": [ "transform-vue-jsx", "transform-runtime", [ "component", { "libraryName": "element-ui", "styleLibraryName": "theme-chalk" } ] ], "env": { "test": { "presets": [ "env", "stage-2" ] } } }
或者
"plugins": [["component", [ { "libraryName": "element-ui", "styleLibraryName": "theme-chalk" } ]]],
如果报错
npm install babel-plugin-component --save-dev
npm run dev