我认为改变颜色的最好方法是使用主题道具或在文档中看起来像这样:
import { flavourOptions } from '../data';
import Select from 'react-select';
export default () => (
<Select
defaultValue={flavourOptions[2]}
label="Single select"
options={flavourOptions}
theme={theme => ({
...theme,
borderRadius: 0,
colors: {
...theme.colors,
primary25: 'hotpink',
primary: 'black',
},
})}
/>
);
Run Code Online (Sandbox Code Playgroud)
但是,我并没有被困在弄清楚如何“连接”它的黑暗模式切换上。
我知道有这样的问题,但我的有点不同,它已经有效,但我不知道如何简化它。
if (location.pathname === `/` || location.pathname ===`/kurikulum/` || location.pathname === `/pengembangan-diri/` || location.pathname === `/statistik/` || location.pathname === `/teknologi/` || location.pathname === `/ekonomi/` || location.pathname === `/desain/` || location.pathname === `/corona/`)
正如你所看到的,它并不漂亮,我想知道我们可以不重复 location.pathname吗?
这是在 gatsby 上,但这是一个 javascript 问题