我在一个全球性的style.css中找到了这个:
:root {
--font: {
font-family: "Source Sans Pro", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
}..。在react组件的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声明自定义属性集。
发布于 2016-10-17 23:56:52
您必须将全局样式表导入本地样式表。因为在解析本地文件时无法了解该全局文件。因此,最好只使用自定义属性和自定义属性集声明。
你可能想要像postcss-进口这样的东西
@import 'path/to/variables.css';
.rightnav {
@apply --font;
float: right;
color: white;
}https://stackoverflow.com/questions/40069506
复制相似问题