[英]Unable to import CSS modules into React TypeScript project #121
Describe the bug In my React Typescript project, I am trying to use CSS modules.描述错误在我的 React Typescript 项目中,我正在尝试使用 CSS 模块。 I created the project using create-react-app , added TypeScript later.我使用create-react-app创建了项目,后来添加了 TypeScript。 Then I followed the instructions from the docs to setup CSS modules in the project然后我按照文档中的说明在项目中设置 CSS 模块
npm install -D typescript-plugin-css-modules
添加了带有npm install -D typescript-plugin-css-modules
{
"compilerOptions": {
"plugins": [{ "name": "typescript-plugin-css-modules" }]
}
}
To Reproduce重现
Expected behavior Home link color should be white预期行为主页链接颜色应为白色
Since you already solved the issue, please have a look for description: problem in accessing the scss variables in react components由于您已经解决了该问题,请查看描述: Problem in access the scss variables in react components
in a similar way you can access classes from the module scss files.以类似的方式,您可以从模块 scss 文件中访问类。
Never mind, changing the name of the scss file to header.module.scss fixed the issue.没关系,将 scss 文件的名称更改为header.module.scss解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.