Vue3(二)集成Ant Design Vue
上一篇文章我們介紹了利用Vue3 創(chuàng)建Vue CLI 項目(一)接下來承接上一篇文章的基礎繼續(xù)展開下面文章的內(nèi)容
一、集成Ant Design Vue
SQL:
npm install ant-design-vue@2.0.0-rc.3 --save
兼容性:
Ant Design Vue 2.x
支持所有的現(xiàn)代瀏覽器。
如果需要支持 IE9+
,你可以使用 Ant Design Vue 1.x & Vue 2.x
。
對于 IE 系列瀏覽器,需要提供 es5-shim
和 es6-shim
等 Polyfills
的支持。
二、組件的使用
官網(wǎng)地址:https://2x.antdv.com/docs/vue/getting-started-cn
1、完整引用
在main.ts中修改內(nèi)容如下:
ts import { createApp } from 'vue'; import Antd from 'ant-design-vue'; import App from './App.vue'; import 'ant-design-vue/dist/antd.css'; import router from './router'; import store from './store'; //優(yōu)點就是方便開發(fā),缺點就是打包的時候會使文件較大(但不并影響什么) createApp(App).use(store).use(router).use(Antd).mount('#app')
2、組件引用
完整引入后,我們就能快樂的使用組件了,如果你之前使用過Vue2.0
或者 Element UI
相對上后會更快。
三、組件使用示例
我們來為home
主頁,添加一個按鈕,如下圖:
1、我們在home主頁做修改
HTML:
<template> <div class="home"> <a-button type="primary" danger>Primary</a-button> <img alt="Vue logo" src="../assets/logo.png"> <HelloWorld msg="Welcome to Your Vue.js + TypeScript App"/> </div> </template> <script lang="ts"> import { defineComponent } from 'vue'; import HelloWorld from '@/components/HelloWorld.vue'; // @ is an alias to /src export default defineComponent({ name: 'Home', components: { HelloWorld, }, }); </script>
2、重新啟動服務查看效果
雙擊server
啟動,查看結(jié)果如下圖:
四、總結(jié)
到此這篇關(guān)于Vue3
集成Ant Design Vue
的文章就介紹到這了,更多相關(guān)Vue3集成Ant Design Vue
內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Vue結(jié)合Video.js播放m3u8視頻流的方法示例
本篇文章主要介紹了Vue+Video.js播放m3u8視頻流的方法示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-05-05vue+springboot實現(xiàn)圖形驗證碼Kaptcha的示例
圖形驗證碼是做網(wǎng)站常用的功能,本文主要介紹了vue+springboot實現(xiàn)圖形驗證碼Kaptcha的示例,具有一定的參考價值,感興趣的可以了解一下2023-11-11