ts依賴引入報(bào)錯(cuò):無法找到模塊“xxxxxx”的聲明文件問題解決
依賴引入報(bào)錯(cuò)是因?yàn)?code>ts沒有識別當(dāng)前引入的依賴,在vite-env.d.ts
中聲明該依賴即可解決,語法:declare module "依賴名";
declare module "file-saver";
解決找不到模塊“./App.vue”或其相應(yīng)的類型聲明。
declare module "*.vue" { import { DefineComponent } from "vue"; const component: DefineComponent<{}, {}, any>; export default component; }
解決router引入報(bào)錯(cuò)的問題
declare module '*./router' { import type { DefineComponent } from 'vue-router' const component: DefineComponent<{}, {}, any> export default component }
declare module 'vue-router'
一些依賴報(bào)錯(cuò)問題的解決
// <reference types="vite/client" /> // 解決引入vue的報(bào)錯(cuò) declare module "*.vue" { import { DefineComponent } from "vue"; const component: DefineComponent<{}, {}, any>; export default component; } // 解決引入scss報(bào)錯(cuò)問題 declare module "*.scss" { const scss: Record<string, string>; export default scss; } // 解決引入模塊的報(bào)錯(cuò)提示 declare module "vuedraggable/src/vuedraggable"; declare module "@pureadmin/components"; declare module "@pureadmin/theme"; declare module "@pureadmin/theme/dist/browser-utils"; declare module "nprogress"; declare module "file-saver"; declare module "element-plus/dist/locale/zh-cn.mjs"; /*解決element-plus國際化依賴報(bào)錯(cuò)*/ /* 解決axios報(bào)錯(cuò):類型“{ params: any; "": any; }”的參數(shù)不能賦給類型“AxiosRequestConfig<any> 解決:屬性“xxxxx”在類型”{ $: ComponentInternalInstance; $data : {}; $props:Part......報(bào)錯(cuò)問題 */ declare module "axios" { export interface AxiosRequestConfig { // 添加數(shù)據(jù)類型 handlerEnabled?: boolean; baseURL: string; timeout: number; } } // 處理TS數(shù)據(jù)類型問題 類型“AxiosResponse<any, any>”上不存在屬性“meta”。 declare module "axios" { interface AxiosResponse<T = any> { meta: any; // 這里追加你的參數(shù) baseURL?: string; timeout?: number; } export function create(config?: AxiosRequestConfig): AxiosInstance; }
總結(jié)
到此這篇關(guān)于ts依賴引入報(bào)錯(cuò):無法找到模塊“xxxxxx”的聲明文件問題解決的文章就介紹到這了,更多相關(guān)ts無法找到模塊xxxxxx的聲明文件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
javascript閉包(Closure)用法實(shí)例簡析
這篇文章主要介紹了javascript閉包(Closure)用法,結(jié)合實(shí)例形式較為詳細(xì)的分析了JavaScript閉包的概念、功能及使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-11-11JavaScript判斷表單提交時(shí)哪個(gè)radio按鈕被選中的方法
這篇文章主要介紹了JavaScript判斷表單提交時(shí)哪個(gè)radio按鈕被選中的方法,實(shí)例分析了javascript操作表單radio按鈕的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-03-03JavaScript數(shù)組常用方法實(shí)例講解總結(jié)
這篇文章主要介紹了JavaScript數(shù)組及常見方法,結(jié)合實(shí)例形式總結(jié)分析了JavaScript數(shù)組的基本獲取、添加、刪除、排序、翻轉(zhuǎn)等相關(guān)操作技巧,需要的朋友可以參考下2021-09-09JS實(shí)現(xiàn)網(wǎng)頁搶購功能(觸發(fā),終止腳本)
小編通過一個(gè)網(wǎng)頁式的搶購功能的實(shí)現(xiàn)給大家講解一下JS如何觸發(fā)和終止腳本來完成這個(gè)任務(wù)。2017-11-11將json轉(zhuǎn)換成struts參數(shù)的方法
下面小編就為大家?guī)硪黄獙son轉(zhuǎn)換成struts參數(shù)的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-11-11