common-mini-components
Version:
公共组件
18 lines (16 loc) • 648 B
text/typescript
import {App} from 'vue'
// TODO 导入 @/components/preview 会报红,需要在 tsconfig.json path中添加"@/*": ["src/*"]
// 当导入 '@/components/preview/Preview.vue' 不会报红,可能是当使用别名引入 .ts 文件时需要在 tsconfig.json path 中也添加和 vite.config.ts 别名中一样,否则会报红
import Preview from '@/components/preview'
// import Preview from './preview'
const components = [Preview]
const globalComponentsPlugin = {
install(app: App) {
components.forEach(plugin => {
app.use(plugin)
})
}
}
export const setupComponents = (app: App) => {
globalComponentsPlugin.install(app)
}