webpack中按需引入mint-UI报Error: .plugins[0][1] must be an object, false, or undefined
webpack中按需引入mint-UI报Error: .plugins[0][1] must be an object, false, or undefined
Mint-UI官方文档:https://mint-ui.github.io/docs/#/en2/quickstart
按需引入mint-UI的步骤:
- 安装
npm install --save mint-ui
- 安装
npm install babel-plugin-component -D
- 配置 .babelrc
{
"presets": [
["@babel/preset-env", { "modules": false }]
],
"plugins": [
["component",
{
"libraryName": "mint-ui",
"style": true
}
]
]
}
- main.js中引入mint-UI
import { Button} from 'mint-ui'
Vue.component(Button.name, Button)
var vm = new Vue({
el:"#app",
render:c=>c(app)
});
- App.vue中使用组件
<mt-button type="danger" size="normal" icon='more'>danger</mt-button>
根据官网文档配置 .babelrc时,报错Error: .plugins[0][1] must be an object, false, or undefined,要去掉component后面的[]
"plugins": [["component", [//去掉此处的[],即可正常运行
{
"libraryName": "mint-ui",
"style": true
}
]]]
原创地址: https://blog.csdn.net/weixin_42869547/article/details/96727386