当前位置:   article > 正文

vue3按需自动导入组件unplugin-auto-import,vue/cli版本_unplugin-auto-import vue动态组件问题

unplugin-auto-import vue动态组件问题

vue3按需自动导入组件,vue/cli版本

1.安装两个插件

package.json的devDependencies,然后npm install

 "unplugin-auto-import": "^0.11.2",
 "unplugin-vue-components": "^0.22.7"
  • 1
  • 2

2.在vue.config.js中配置

const {defineConfig} = require('@vue/cli-service')

const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const {ElementPlusResolver} = require('unplugin-vue-components/resolvers')

module.exports = defineConfig({

    configureWebpack: (config) => {
        if (!config.plugins) {
            config.plugins = []
        }
        config.plugins.push(
            AutoImport({
                resolvers: [ElementPlusResolver()]
            })
        )
        config.plugins.push(
            Components({
                resolvers: [ElementPlusResolver()]
            })
        )
    }

})
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/86190
推荐阅读
相关标签
  

闽ICP备14008679号