vant-demo icon indicating copy to clipboard operation
vant-demo copied to clipboard

vite下vant4如何按需显式引入

Open cz132023cz opened this issue 3 months ago • 0 comments

vite下vant4按需引入的疑问:

1、直接在vue组件写 import { Button as vanButton } from 'vant' import 'vant/es/button/style' 而不用在vite.config做任何配置

2、直接在vite.config写 AutoImport({resolvers: [VantResolver()],}), Components({resolvers: [VantResolver()],}), 而在组件不用显式引入(此时显式引入会导致样式丢失)

3、但是我的想法是,仅仅在组件引入import { Button as vanButton } from 'vant',而不引入样式。这种该如何配置(才不会导致样式丢失)?

cz132023cz avatar Sep 17 '25 07:09 cz132023cz