[Vue] component ant design of vue

Install

npm install [email protected] --save
npm i --save ant-design-vue@next

npm i --save ant-design-vue //目前使用的兼容版本"ant-design-vue": "^2.2.8",

The project introduces global components

insert image description here

common problem

keyword to avoid

insert image description here

Handle validation exceptions es-link

error The “HelloWorld” component has been registered but not used vue/no-unused-components
insert image description here

stack overflow

insert image description here
insert image description here

ant gallery not loaded

insert image description here

git

Append to last commit file

insert image description here

easy to use

Custom component-header

Components can, small hump big hump, - link

the-header component

<template>
    <a-layout-header class="header">
        <div class="logo" />
        <a-menu
                theme="dark"
                mode="horizontal"
                v-model:selectedKeys="selectedKeys1"
                :style="{ lineHeight: '64px' }"
        >
            <a-menu-item key="1">nav 11</a-menu-item>
            <a-menu-item key="2">nav 2</a-menu-item>
            <a-menu-item key="3">nav 3</a-menu-item>
        </a-menu>
    </a-layout-header>
</template>

<script lang="ts">
    import {
    
     defineComponent } from 'vue';

    export default defineComponent({
    
    
        name: 'the-header'
    });
</script>

<style scoped>

</style>

reference component

 <the-header></the-header>

<script lang="ts">
  import {
    
     defineComponent } from 'vue';
  import  TheHeader from '@/components/the-header.vue';
  export default defineComponent({
    
    
    name: 'app',
    components: {
    
    
      TheHeader,
    }
  });
</script>

the list

add any question ts type

insert image description here
ts type any becomes js unlimited type, if there is an error message
insert image description here

icon iocn

Install npm install @ant-design/icons-vue --save
main.ts to import globally, the official document seems to need to introduce troubles one by one

import * as Icons from '@ant-design/icons-vue';

// createApp(App).use(store).use(router).use(Antd).mount('#app'); // 链式变动
const app = createApp(App);
app.use(store).use(router).use(Antd).mount('#app');

// 全局使用图标
const icons: any = Icons;
for (const i in icons) {
    
    
    app.component(i, icons[i]);
}

Guess you like

Origin blog.csdn.net/weixin_43469680/article/details/121112561