vue3中如果注册的是局部组件,那么props是有类型提示的,但是如果注册的是全局组件,props就没有类型提示了
参考1:How to make VSCode recognize global component in Vue?
参考2:https://github.com/element-plus/element-plus/blob/dev/global.d.ts
解决方法
- src目录下 创建 global.d.ts文件
- 参考一下代码
// 因 vue3 + ts 还没有那么完善
// 全局注册的组件没有类型提示 一下为解决办法
import XtxSkeleton from '@/components/skeleton/index.vue'
// 参考:
declare module 'vue' {
export interface GlobalComponents {
XtxSkeleton: typeof XtxSkeleton
}
}
export {}