«

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

时间:2023-8-10 10:28     作者:小诸葛     分类: 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
}

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

推荐阅读:


扫描二维码,在手机上阅读