感觉本人写代码有强迫症,每当看到一个文件乱糟糟的就不舒服,为了文件代码美观所以将main.ts中有关引入vant的代码分离出来:

main.ts

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import vant from './vant'
export const app = createApp(App)

app.use(router)
app.use(vant)

app.mount('#app')

src目录下新建vant文件夹,然后下面新建index.ts,内容如下:

import { Form, Field, CellGroup, Button } from 'vant'

export default {
  install: function (Vue: any) {
    Vue.use(Form)
    Vue.use(Field)
    Vue.use(CellGroup)
    Vue.use(Button)
  },
}

element同理


雨顺
1 声望0 粉丝