简体   繁体   中英

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. In NextJs everything ok, but fro React, it does not accept how CSS is loaded:

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

In react you simply import it as
import "../../styles/buyTicket.module.css";

Then in your element className is defined like vanilla html
<div className="class"></div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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