如何在基于 React 的 Wordpress 插件中使用 CSS 模块?
How to use CSS modules in a React based Wordpress plugin?
我的一个 tsx
文件中有这一行:
import styles from "../../styles/buyTicket.module.css";
收到此错误:
ERROR in /Applications/MAMP/htdocs/wp-content/plugins/tikex/tikexModule/components/BuyTicket/PricingOptionInvoiceItemsFormFieldsCheckboxes.tsx
./tikexModule/components/BuyTicket/PricingOptionInvoiceItemsFormFieldsCheckboxes.tsx 7:19-54
[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.
如果我删除 styles
然后我就不会再收到这个错误,但是它不会像 CSS 模块一样工作,并且会发生命名冲突。你有什么建议?
据我所知,你可以看这里:
Can't import CSS/SCSS modules. TypeScript says "Cannot Find Module"
这里:
React, Typescript - Cannot find module ... or its corresponding type declarations
我的一个 tsx
文件中有这一行:
import styles from "../../styles/buyTicket.module.css";
收到此错误:
ERROR in /Applications/MAMP/htdocs/wp-content/plugins/tikex/tikexModule/components/BuyTicket/PricingOptionInvoiceItemsFormFieldsCheckboxes.tsx
./tikexModule/components/BuyTicket/PricingOptionInvoiceItemsFormFieldsCheckboxes.tsx 7:19-54
[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.
如果我删除 styles
然后我就不会再收到这个错误,但是它不会像 CSS 模块一样工作,并且会发生命名冲突。你有什么建议?
据我所知,你可以看这里:
Can't import CSS/SCSS modules. TypeScript says "Cannot Find Module"
这里:
React, Typescript - Cannot find module ... or its corresponding type declarations