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

varlet-ui组件自动导入样式,添加ImagePreview #544

Merged
merged 1 commit into from
Nov 3, 2022

Conversation

wtto00
Copy link
Contributor

@wtto00 wtto00 commented Nov 2, 2022

varlet-ui组件库,组件ImagePreview
https://varlet.gitee.io/varlet-ui/#/zh-CN/image-preview

Description

vite+vue3项目中,varlet-ui组件库不能自动导入组件ImagePreview

// vite.config.ts
import autoImport from 'unplugin-auto-import/vite';
import { VarletUIResolver } from 'unplugin-vue-components/resolvers';

export default defineConfig({
  plugins: [
    autoImport({
      resolvers: [VarletUIResolver({ autoImport: true })],
      eslintrc: { enabled: true },
    })
  ]
});

Linked Issues

Additional context

可以通过下面配置暂时解决:

// vite.config.ts
import autoImport from 'unplugin-auto-import/vite';
import { VarletUIResolver, getResolved } from 'unplugin-vue-components/resolvers';

export default defineConfig({
  plugins: [
    autoImport({
      resolvers: [
        VarletUIResolver({ autoImport: true }),
        [(name: string) => (name === 'ImagePreview' ? getResolved('ImagePreview', { autoImport: true }) : undefined)]
      ],
      eslintrc: { enabled: true },
    })
  ]
});

@wtto00 wtto00 requested a review from haoziqaq as a code owner November 2, 2022 22:48
@haoziqaq haoziqaq merged commit c1ffcd6 into unplugin:main Nov 3, 2022
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

Successfully merging this pull request may close these issues.

None yet

3 participants