引入.vue文件提示“Could not find a declaration file for module 'xxx.vue'......”

有时候在开发过程中只是提示有错,不影响项目运行,但在打包时会报错,导致无法打包。

在src文件目录下(也就是你开发代码所在的文件夹)添加 shims-vue.d.ts 文件,内容为

declare module '*.vue' {

    import { DefineComponent } from 'vue';



    const component: DefineComponent<{}, {}, any>;

    export default component;

}

引入.js 文件提示报错,找不到时在src文件下添加 shims.d.ts 文件,内容为

declare module "*.js";

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐