![](/img/trans.png)
[英]Cannot find module 'react-lazily' or its corresponding type declarations
[英]TS2307: Cannot find module './tables.module.css' or its corresponding type declarations
所以我在 create-react-app 項目中使用 css 模塊,由於某種原因我有這個錯誤:
在谷歌瀏覽器中:
然而,這似乎是 eslint 錯誤,因為在瀏覽器中我可以關閉警告模式並且我的所有 styles 都已應用並且應用程序按預期工作。
表格.tsx
import styles from "./Tables.module.css";
export const Tables = () => {
return (
<div className={styles.card}>Tables</div>
)
}
表.module.css
.card {
background: red;
width: 100px;
height: 100px;
}
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}
文件夾結構:
我在這里缺少什么? 提前感謝您的回答。
我相信 typescript 沒有將 CSS 文件識別為一個模塊,所以它會拋出一個錯誤,讓你找不到那個名字的文件。
這個問題的答案可能有助於作為參考。 如果這沒有幫助,我認為模塊的路徑解析可能存在問題,所以這里是 typescript 解析模塊/路徑的方式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.