简体   繁体   English

为什么 css 不能在 React 中加载,而只能在 Next.js 中加载?

[英]Why css can not load in React but only in Next.js?

We have a component, which is in a Git Submodule, because a NExt.js and a React is using it also.我们有一个组件,它位于 Git 子模块中,因为 NExt.js 和 React 也在使用它。 In NextJs everything ok, but fro React, it does not accept how CSS is loaded:在 NextJs 中一切正常,但对于 React,它不接受 CSS 的加载方式:

import styles from "../../styles/buyTicket.module.css";
[tsl] ERROR in /Applications/MAMP/htdocs/wp-content/plugins/tikex/tikexModule/components/BuyTicket/PricingOptionInvoiceItemsFormFieldsCheckboxes.tsx(7,20)
      TS2307: Cannot find module '../../styles/buyTicket.module.css' or its corresponding type declarations.
 @ ./app/containers/Tiket/Test.tsx 2:0-148 36:88-133
 @ ./app/containers/Test.jsx 3:0-32 6:44-48
 @ ./app/shortcode35.js 8:0-46 14:54-63

What is wrong here?这里有什么问题? css is at the right place css 在正确的位置

In react you simply import it as在反应中,您只需将其导入为
import "../../styles/buyTicket.module.css";

Then in your element className is defined like vanilla html然后在您的元素 className 中定义为 vanilla html
<div className="class"></div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM