1. Use version
- vite:2.0
- ant-design-vue: 2.0.0-rc.8
- vue:3.0.5
2. Install vite plugin
yarn add vite-plugin-style-import -D or npm i vite-plugin-style-import -D
Plugin repository address:github
Configuration
import vue from '@vitejs/plugin-vue' import styleImport from 'vite-plugin-style-import'; /** * @type {import('vite').UserConfig} */ export default { plugins: [ vue(), styleImport({ libs: [{ libraryName: 'ant-design-vue', esModule: true, resolveStyle: (name) => { return `ant-design-vue/es/${name}/style/css`; }, }] }) ] }
4. Test run
import { createApp } from 'vue' import App from './' import { Input } from 'ant-design-vue'; const app=createApp(App) (Input) ('#app')
Used in components
<template> <!-- script-setupIntroduced and used,No registration required--> <Button type="primary"> Primary</Button> <!-- In useuseRegister components --> <a-input placeholder="Basic usage" /> </template> <script setup> import { Button } from "ant-design-vue"; </script>
This is the article about implementing the method of loading ant-design-vue@next components on demand. For more related content on demand, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!