【问题标题】:Why css can not load in React but only in Next.js?为什么 css 不能在 React 中加载而只能在 Next.js 中加载?
【发布时间】:2022-01-13 05:12:49
【问题描述】:

我们有一个组件,它位于 Git 子模块中,因为 NExt.js 和 React 也在使用它。在 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

这里有什么问题? CSS在正确的地方

【问题讨论】:

标签: javascript css reactjs


【解决方案1】:

在反应中,您只需将其导入为
import "../../styles/buyTicket.module.css";

然后在你的元素中 className 被定义为 vanilla html
<div className="class"></div>

【讨论】:

猜你喜欢
  • 2020-08-03
  • 1970-01-01
  • 2010-12-09
  • 2019-12-24
  • 2021-04-16
  • 2022-01-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多