最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue中ant-design-vue組件的安裝與使用

 更新時(shí)間:2022年04月22日 10:56:07   作者:Dawnlighttt  
Ant Design Vue是使用Vue實(shí)現(xiàn)的遵循Ant Design設(shè)計(jì)規(guī)范的高質(zhì)量UI組件庫(kù),用于開發(fā)和服務(wù)于企業(yè)級(jí)中后臺(tái)產(chǎn)品,下面這篇文章主要給大家介紹了關(guān)于vue中ant-design-vue組件安裝與使用的相關(guān)資料,需要的朋友可以參考下

官方地址:Ant Design Vue

1. 安裝

首先使用vue-cli創(chuàng)建項(xiàng)目,然后進(jìn)入項(xiàng)目,使用npm安裝ant-design-vue庫(kù):

npm i --save ant-design-vue@next

然后在package.json文件中的dependencies中看見剛剛下載的庫(kù):

2. 引入組件庫(kù)

然后在main.js中引入,注意要按照順序:

# 引入組件庫(kù)
import ant from 'ant-design-vue'
# 引入樣式表
import 'ant-design-vue/dist/antd.css'

引入順序如圖所示:

接著需要use該組件庫(kù)的句柄:

然后在要使用的vue文件中也引入組件庫(kù),比如我要在項(xiàng)目默認(rèn)的App.vue中使用組件庫(kù):

import 'ant-design-vue/dist/antd'

3. 使用

3.1 按鈕樣式

直接將代碼復(fù)制到component標(biāo)簽中即可,要注意component標(biāo)簽中只能允許有一個(gè)根標(biāo)簽。

3.2 導(dǎo)航欄樣式

可以選擇顏色的導(dǎo)航欄

<template>
  <div>
    <a-switch :checked="mode === 'vertical'" @change="changeMode" />
    Change Mode
    <span class="ant-divider" style="margin: 0 1em" />
    <a-switch :checked="theme === 'dark'" @change="changeTheme" />
    Change Theme
    <br />
    <br />
    <a-menu
      style="width: 256px"
      v-model:openKeys="openKeys"
      v-model:selectedKeys="selectedKeys"
      :mode="mode"
      :theme="theme"
    >
      <a-menu-item key="1">
        <template #icon>
          <MailOutlined />
        </template>
        Navigation One
      </a-menu-item>
      <a-menu-item key="2">
        <template #icon>
          <CalendarOutlined />
        </template>
        Navigation Two
      </a-menu-item>
      <a-sub-menu key="sub1">
        <template #icon>
          <AppstoreOutlined />
        </template>
        <template #title>Navigation Three</template>
        <a-menu-item key="3">Option 3</a-menu-item>
        <a-menu-item key="4">Option 4</a-menu-item>
        <a-sub-menu key="sub1-2" title="Submenu">
          <a-menu-item key="5">Option 5</a-menu-item>
          <a-menu-item key="6">Option 6</a-menu-item>
        </a-sub-menu>
      </a-sub-menu>
      <a-sub-menu key="sub2">
        <template #icon>
          <SettingOutlined />
        </template>

        <template #title>Navigation Four</template>
        <a-menu-item key="7">Option 7</a-menu-item>
        <a-menu-item key="8">Option 8</a-menu-item>
        <a-menu-item key="9">Option 9</a-menu-item>
        <a-menu-item key="10">Option 10</a-menu-item>
      </a-sub-menu>
    </a-menu>
  </div>
</template>
<script>
import { defineComponent, reactive, toRefs } from 'vue';
import {
  MailOutlined,
  CalendarOutlined,
  AppstoreOutlined,
  SettingOutlined,
} from '@ant-design/icons-vue';
export default defineComponent({
  setup() {
    const state = reactive({
      mode: 'inline',
      theme: 'light',
      selectedKeys: ['1'],
      openKeys: ['sub1'],
    });

    const changeMode = checked => {
      state.mode = checked ? 'vertical' : 'inline';
    };

    const changeTheme = checked => {
      state.theme = checked ? 'dark' : 'light';
    };

    return { ...toRefs(state), changeMode, changeTheme };
  },

  components: {
    MailOutlined,
    CalendarOutlined,
    AppstoreOutlined,
    SettingOutlined,
  },
});
</script>

頂部導(dǎo)航欄

<template>
  <a-menu v-model:selectedKeys="current" mode="horizontal">
    <a-menu-item key="mail">
      <template #icon>
        <mail-outlined />
      </template>
      Navigation One
    </a-menu-item>
    <a-menu-item key="app" disabled>
      <template #icon>
        <appstore-outlined />
      </template>
      Navigation Two
    </a-menu-item>
    <a-sub-menu>
      <template #icon>
        <setting-outlined />
      </template>
      <template #title>Navigation Three - Submenu</template>
      <a-menu-item-group title="Item 1">
        <a-menu-item key="setting:1">Option 1</a-menu-item>
        <a-menu-item key="setting:2">Option 2</a-menu-item>
      </a-menu-item-group>
      <a-menu-item-group title="Item 2">
        <a-menu-item key="setting:3">Option 3</a-menu-item>
        <a-menu-item key="setting:4">Option 4</a-menu-item>
      </a-menu-item-group>
    </a-sub-menu>
    <a-menu-item key="alipay">
      <a  target="_blank" rel="noopener noreferrer">
        Navigation Four - Link
      </a>
    </a-menu-item>
  </a-menu>
</template>
<script>
import { defineComponent, ref } from 'vue';
import { MailOutlined, AppstoreOutlined, SettingOutlined } from '@ant-design/icons-vue';
export default defineComponent({
  setup() {
    const current = ref(['mail']);
    return {
      current,
    };
  },

  components: {
    MailOutlined,
    AppstoreOutlined,
    SettingOutlined,
  },
});
</script>

3.3 表單樣式

內(nèi)聯(lián)登錄欄

<template>
  <a-form
    layout="inline"
    :model="formState"
    @finish="handleFinish"
    @finishFailed="handleFinishFailed"
  >
    <a-form-item>
      <a-input v-model:value="formState.user" placeholder="Username">
        <template #prefix><UserOutlined style="color: rgba(0, 0, 0, 0.25)" /></template>
      </a-input>
    </a-form-item>
    <a-form-item>
      <a-input v-model:value="formState.password" type="password" placeholder="Password">
        <template #prefix><LockOutlined style="color: rgba(0, 0, 0, 0.25)" /></template>
      </a-input>
    </a-form-item>
    <a-form-item>
      <a-button
        type="primary"
        html-type="submit"
        :disabled="formState.user === '' || formState.password === ''"
      >
        Log in
      </a-button>
    </a-form-item>
  </a-form>
</template>
<script>
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue';
import { defineComponent, reactive } from 'vue';
export default defineComponent({
  setup() {
    const formState = reactive({
      user: '',
      password: '',
    });

    const handleFinish = values => {
      console.log(values, formState);
    };

    const handleFinishFailed = errors => {
      console.log(errors);
    };

    return {
      formState,
      handleFinish,
      handleFinishFailed,
    };
  },

  components: {
    UserOutlined,
    LockOutlined,
  },
});
</script>

補(bǔ)充:ant-design-vue的兼容問題

問題:ant-design-vue不兼容ie瀏覽器

要求:ie兼容 >= 9

環(huán)境:vue cli3搭建項(xiàng)目,ant-design-vue@1.3.8

babel.config.js文件

module.exports = {
  presets: [
    '@vue/app',
    // 兼容配置
    [
      '@babel/preset-env',
      {
        'useBuiltIns': 'entry'
      }
    ]
  ],
  // 按需加載配置
  plugins: [
    [
      'import',
      {
        libraryName: 'ant-design-vue',
        libraryDirectory: 'es',
        style: 'css'
      },
    ]
  ]
}

main.js文件(項(xiàng)目入口)

// 引入@babel/polyfill處理兼容?
import '@babel/polyfill'

import Vue from 'vue'
import App from './App.vue'
import router from './router/router'
import store from './store/store'
import './plugins/antd.js'
new Vue({
? router,
? store,
? render: h => h(App)
}).$mount('#app')

總結(jié)

到此這篇關(guān)于vue中ant-design-vue組件安裝與使用的文章就介紹到這了,更多相關(guān)vue ant-design-vue組件使用內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • vue如何統(tǒng)一樣式(reset.css與border.css)

    vue如何統(tǒng)一樣式(reset.css與border.css)

    這篇文章主要介紹了vue如何統(tǒng)一樣式(reset.css與border.css),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-05-05
  • Vue Router路由動(dòng)態(tài)緩存組件使用詳解

    Vue Router路由動(dòng)態(tài)緩存組件使用詳解

    這篇文章主要介紹了Vue Router路由動(dòng)態(tài)緩存組件使用,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2025-04-04
  • 淺談vue 二級(jí)路由嵌套和二級(jí)路由高亮問題

    淺談vue 二級(jí)路由嵌套和二級(jí)路由高亮問題

    這篇文章主要介紹了淺談vue 二級(jí)路由嵌套和二級(jí)路由高亮問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-08-08
  • Vue組件化開發(fā)之通用型彈出框的實(shí)現(xiàn)

    Vue組件化開發(fā)之通用型彈出框的實(shí)現(xiàn)

    這篇文章主要介紹了Vue組件化開發(fā)之通用型彈出框的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-02-02
  • vue登錄頁(yè)面設(shè)置驗(yàn)證碼input框的方法

    vue登錄頁(yè)面設(shè)置驗(yàn)證碼input框的方法

    這篇文章主要為大家詳細(xì)介紹了vue登錄頁(yè)面設(shè)置驗(yàn)證碼input框的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • Vue.js中的下載和調(diào)用方式

    Vue.js中的下載和調(diào)用方式

    這篇文章主要介紹了Vue.js中的下載和調(diào)用方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-11-11
  • Vue3動(dòng)態(tài)使用KeepAlive組件的實(shí)現(xiàn)步驟

    Vue3動(dòng)態(tài)使用KeepAlive組件的實(shí)現(xiàn)步驟

    在 Vue 3 項(xiàng)目中,我們有時(shí)需要根據(jù)路由的 meta 信息來動(dòng)態(tài)決定是否使用 KeepAlive 組件,以控制組件的緩存行為,所以本文給大家介紹了Vue3動(dòng)態(tài)使用KeepAlive組件的實(shí)現(xiàn)步驟,通過代碼示例講解的非常詳細(xì),需要的朋友可以參考下
    2024-11-11
  • Vue計(jì)算屬性的學(xué)習(xí)筆記

    Vue計(jì)算屬性的學(xué)習(xí)筆記

    這篇文章主要為大家詳細(xì)介紹了Vue計(jì)算屬性的學(xué)習(xí)筆記,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • Vue+Django項(xiàng)目部署詳解

    Vue+Django項(xiàng)目部署詳解

    這篇文章主要介紹了Vue+Django項(xiàng)目部署詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • Ant Design moment對(duì)象和字符串之間的相互轉(zhuǎn)化教程

    Ant Design moment對(duì)象和字符串之間的相互轉(zhuǎn)化教程

    這篇文章主要介紹了Ant Design moment對(duì)象和字符串之間的相互轉(zhuǎn)化教程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-10-10

最新評(píng)論

光山县| 开原市| 香河县| 行唐县| 东山县| 丁青县| 垣曲县| 乐亭县| 尉氏县| 龙山县| 莎车县| 淄博市| 若羌县| 马龙县| 山阴县| 台南县| 平湖市| 江永县| 湾仔区| 乐业县| 红安县| 石渠县| 阳江市| 黄大仙区| 于田县| 博客| 丽江市| 库车县| 伊川县| 泽州县| 陆良县| 嵊泗县| 湟源县| 临沧市| 平和县| 墨玉县| 梨树县| 始兴县| 泰兴市| 宝丰县| 华阴市|