best way for vue ant design components usage

699 Views Asked by At

i use vue2 ant design library, and have many components with same

import Vue from "vue"
import select from "select"
Vue.use(select)

is the best way usage like this, or i should import all ant design ui in app.vue?

1

There are 1 best solutions below

1
On

If you want to use a lot of antd component across your project it's recommended to register the antd plugin globally to make all the components available without using import {someComponent,...} from 'ant-design-vue' in every component :

import Vue from 'vue';
import Antd from 'ant-design-vue';
import App from './App';
import 'ant-design-vue/dist/antd.css';


Vue.use(Antd);//register all components

new Vue({
  el: '#app',
  components: { App },
  template: '<App/>',
})

if you've a small project you could import the component locally when you need it like:

 import { Button, message } from 'ant-design-vue';