Vue3.0中引用子组件类型声明报错问题
报错原因:
1.找不到组件模块或者找不到对应的类型声明。
2.Typescript 只能理解 .ts 文件,无法理解 .vue 文件。
解决方案:
1.在项目根目录或 src 文件夹下创建一个后缀为 .d.ts 的文件,并写入以下内容:
declare module '*.vue' {
import { ComponentOptions } from 'vue'
const componentOptions: ComponentOptions
export default componentOptions
}
注意事项:
1.名字随意
2.项目重启