使用type script开发vue项目,出现引用vue组件的错误提示,需要使用声明文件(.d.ts)声明组件,在项目中创建vue.d.ts,也可以是其它文件名,内容如下:
/* eslint-disable /
declare module '.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}
.d.ts是为了通知type script编译器所使用的js相关的定义。
网友评论