ant-design-vue2.2.2出来有一段时间了,打的主题是轻量便捷,听到这那必须使用啊,福音啊!
毫不犹豫尝尝,但是不试不知道一入深似海。
好了废话不多说 走一波
先看文档
安装
npm i --save ant-design-vue@next
引用
import { createApp } from 'vue';
import Antd from 'ant-design-vue';
import App from './App';
import 'ant-design-vue/dist/antd.css';
const app = createApp();
app.config.productionTip = false;
app.use(Antd);
按照这样的使用然后就发现了
import { createApp } from 'vue'
import App from './App.vue'
import router from './router/index'
import 'ant-design-vue/dist/antd.css'
import Antd from 'ant-design-vue'
// const app = createApp(App);
createApp(App).use(router).mount('#app')
createApp(App).use(Antd)
屏幕就出现这样的问题
这是按需加载的问题 把router分开使用
错误
import { createApp } from 'vue'
import App from './App.vue'
import router from './router/index'
import 'ant-design-vue/dist/antd.css'
import Antd from 'ant-design-vue'
// const app = createApp(App);
createApp(App).mount('#app')
createApp(App).use(router)
createApp(App).use(Antd)
这样就会发生错误
正确使用方法是
import { createApp } from 'vue'
import App from './App.vue'
import router from './router/index'import 'ant-design-vue/dist/antd.css'import Antd from 'ant-design-vue'
const app = createApp(App);
app .use(router) .mount('#app')
app.use(Antd)