在我的应用程序中,我有多个主题样式(您可以将它们视为不同的、单独的 CSS 样式文件)。我想开始使用 CSS 模块,但我什至不知道如何使用import我的第一个文件。
让我们假设以下(简单)目录结构:
layouts/
themeA/
myComponent.css
themeB/
myComponent.css
themeC/
myComponent.css
components/
myComponent.js
Run Code Online (Sandbox Code Playgroud)
根据用户设置,我想选择不同的 CSS。这在浏览器(或服务器)中很容易做到。但是如何将 myComponent.css 包含到 myComponent.js 中?
根据 CSS 模块,我应该import使用我正在使用的文件。所以import styles from 'theme/myComponent.css。问题是我没有一个真正的主题,而是 3 个不同的平行主题。
import styles from '' // <<<< from what?
return `<div class=${styles.caption></div>`
Run Code Online (Sandbox Code Playgroud)
使用 CSS 模块时甚至可以使用多个布局/主题吗?