今天打算用 unplugin-vue-components 插件按需引入Antd Vue的组件,我使用的vite版本和Antd Vue 版本如图:


我按照官网的做法在vite.config.ts中配置了,下图是官网的截图:

我在项目中抽取了antd.ts的插件配置,代码如下:
# antd.ts
import type { App } from 'vue'
import 'ant-design-vue/dist/reset.css'
import { message } from 'ant-design-vue'
export function setupAntd(app: App<Element>) {
app.config.globalProperties.$message = message
}
然后在main.ts中调用
# main.ts
const app = createApp(App)
setupAntd(app)
然后出来的效果是antd的reset.css 没有加载,效果如下:

最低0.47元/天 解锁文章
7516

被折叠的 条评论
为什么被折叠?



