element-ui tips you need to .babelrc amended as follows:
"presets": [["es2015", { "modules": false }]],
"plugins": [
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
]
}
My vue-cli version 3.9.3, only babel.config.js create files in the project directory. Then modify the
module.exports = {
presets: ["@vue/app", ["es2015", { modules: false }]],
plugins: [
[
"component",
{
libraryName: "element-ui",
styleLibraryName: "theme-chalk"
}
]
]
};
After the modification, re npm run serve, error Error: Can not find module 'babel-preset-es2015'. Installation @ babel / preset-env
npm install --save-dev @babel/preset-env
And modify the file as follows .babel.config.js, after saving the successful run again:
module.exports = {
presets: ["@vue/app", ["@babel/preset-env", { modules: false }]],
plugins: [
[
"component",
{
libraryName: "element-ui",
styleLibraryName: "theme-chalk"
}
]
]
};
Note: where have tried to use babel-preset-es2015, try using this command but will complain. After switching to @ babel / preset-env, this article compares the two, you can reference.
npm install --save-dev babel-preset-es2015
https://github.com/Gesj-yean/vue-demo-collection documented use more outstanding plug-ins. Students have time to look at my top blog can thank you very much.