微语 微语:代码适合中午敲,早晚出BUG

使用vue3+TS提示模块无法找到。 Vue

创建页面也可以正常访问,但是ts报错找不不到模块,可以尝试使用下面方法解决

1.在根目录下面创建 shims-vue.d.ts ,放入下面代码,如果第二和代码段不行,可以尝试第一个。


// declare module '*.vue' {
//     import type { DefineComponent } from 'vue'
//     const component: DefineComponent<{}, {}, any>
//     export default component
// }

declare module '*.vue' {
    import type { DefineComponent } from 'vue'
    const component: ComponentOptions | ComponentOptions['setup']
    export default component
}