2
我在一個全球性的style.css得到這個使用@apply:如何用CSS模塊組件反應
:root {
--font: {
font-family: "Source Sans Pro", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
}
...這在反應組件的style.css:
.rightnav {
@apply --font;
float: right;
color: white;
}
在組件本身:
import React from "react"
import cssModules from "react-css-modules"
import style from "./style.css"
render() {
return (
<ul>
<li className={style.rightnav}>Blog</li>
</ul>
)
}
我得到一個錯誤:沒有自定義屬性中設置申報font
。
。如果有一種方法只導入你需要的css屬性集,而不是導入整個文件,但是我還沒有找到方法,那會很好。 –