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的步骤:

  1. 安装 npm install --save mint-ui
  2. 安装 npm install babel-plugin-component -D
  3. 配置 .babelrc
{
  "presets": [
    ["@babel/preset-env", { "modules": false }]
  ],
  "plugins": [
    ["component",
        {
          "libraryName": "mint-ui",
          "style": true
        }
    ]
  ]
}

 

 

  1. main.js中引入mint-UI
import { Button} from 'mint-ui'
Vue.component(Button.name, Button)


var vm = new Vue({
    el:"#app",
    render:c=>c(app)
});

 

 

  1. 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
posted @ 2020-08-06 09:26  webapp1  阅读(1146)  评论(0编辑  收藏  举报