Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

naiveui 二次封装组件扩展时,使用 unplugin-vue-components 内部的组件没有被识别自动导入 #771

Open
InfernalAzazel opened this issue Jun 12, 2024 · 4 comments

Comments

@InfernalAzazel
Copy link

InfernalAzazel commented Jun 12, 2024

1.同类问题,没有解决

#253

2.关键代码

vite.config.ts

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import { NaiveProResolver } from '@naive-pro/resolver';

const debugResolver = (name) => {
  console.log(`Resolving component: ${name}`);
  return null; // 返回 null 继续下一个解析器
};

const testProResolver = (name: string) => {
  console.log('啊哈哈', name)
  return {
    name: name,
    from: `@naive-pro/components`,
    sideEffects: `@naive-pro/components/es/style.css`,
  };
}

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    Components({
      resolvers: [
        NaiveUiResolver(),
        NaiveProResolver()
      ]
    })
  ],
})

3.代码复现

4.异常效果

2024-06-12 17-40-09屏幕截图

5.只有全局注册 naiveui 才能正常使用,按需就不行。

image
image
image

@pht2001
Copy link

pht2001 commented Jun 26, 2024

试试多加一个配置 version
Components({
version: 3,
.......
})

@InfernalAzazel
Copy link
Author

尝试多加一个配置版本 Components({ version: 3, ....... })

加了,没有一点效果

@pbchan007
Copy link

n: 3,

有效,it works

@InfernalAzazel
Copy link
Author

n: 3,

有效,it works

我之前试过很多次,要不你pr一下我上面提供的仓库?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants