unplugin-vue-components icon indicating copy to clipboard operation
unplugin-vue-components copied to clipboard

如何配置才能不使用{}解构,而是直接导入

Open dsmelon opened this issue 9 months ago • 1 comments

Describe the bug

由于组件库没有按需导出所有组件,我想从它的目录按需导入,如何配置才能实现,例如以下写法 import SelfButton from '@self/component/button' import SelfForm from '@self/component/form'

Reproduction

System Info

version: 0.21.2

Used Package Manager

yarn

Validations

  • [X] Follow our Code of Conduct
  • [X] Read the Contributing Guide.
  • [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • [X] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • [X] The provided reproduction is a minimal reproducible of the bug.

dsmelon avatar Apr 26 '24 11:04 dsmelon

不知道我的方案适不适用于你的情况, 例如我是用 vue-echarts 这个库, 需要 import VChart from vue-echarts 我配置成这样可以正确使用

Components({
  dts: true,
  resolvers: [
    (componentName: string) => {
      if (componentName === 'VChart')
        return 'vue-echarts'
    },
  ],
}),

kuolemax avatar May 05 '24 09:05 kuolemax