主题化由fabric ui制作的react网站时出现问题
我已经使用Fabric UI提供的用于生成主题的网站生成了2个主题(夜间/白天模式)。我以json格式导出了它们。 因为我想使用切换按钮在这两个主题之间进行切换,所以这两个json成为文件“ Themes.json”中的变量
问题在于,一旦我更改了主题,应该是深色的身体背景实际上就是纯白色
我的主题
var lightCyan = {
"themePrimary": "#009486",
"themeLighterAlt": "#f1fbfa",
"themeLighter": "#c8eeea",
"themeLight": "#9cdfd8",
"themeTertiary": "#4cbfb4",
"themeSecondary": "#13a193",
"themeDarkAlt": "#008578",
"themeDark": "#007166",
"themeDarker": "#00534b",
"neutralLighterAlt": "#f8f8f8",
"neutralLighter": "#f4f4f4",
"neutralLight": "#eaeaea",
"neutralQuaternaryAlt": "#dadada",
"neutralQuaternary": "#d0d0d0",
"neutralTertiaryAlt": "#c8c8c8",
"neutralTertiary": "#595959",
"neutralSecondary": "#373737",
"neutralPrimaryAlt": "#2f2f2f",
"neutralPrimary": "#000000",
"neutralDark": "#151515",
"black": "#0b0b0b",
"white": "#ffffff"
}
var darkCyan = {
"themePrimary": "#4fedec",
"themeLighterAlt": "#030909",
"themeLighter": "#0d2626",
"themeLight": "#184747",
"themeTertiary": "#2f8e8e",
"themeSecondary": "#45d1d0",
"themeDarkAlt": "#5fefee",
"themeDark": "#77f2f1",
"themeDarker": "#99f5f4",
"neutralLighterAlt": "#151717",
"neutralLighter": "#1e2020",
"neutralLight": "#2c302f",
"neutralQuaternaryAlt": "#353939",
"neutralQuaternary": "#3d4141",
"neutralTertiaryAlt": "#5c6161",
"neutralTertiary": "#c8c8c8",
"neutralSecondary": "#d0d0d0",
"neutralPrimaryAlt": "#dadada",
"neutralPrimary": "#ffffff",
"neutralDark": "#f4f4f4",
"black": "#f8f8f8",
"white": "#0c0d0c",
"bodyBackground":"#2e2a2a"
}
export {lightCyan, darkCyan};
答案 0 :(得分:0)
如您所见,当您加载主题时,FluentUI不会不更改主体背景。您可以用一行代码来解决此问题,您可以将其添加到加载主题的函数中:
document.documentElement.style.background = paletteNext === "white" ? "black" : "white";
如果您对我的主题切换方法感兴趣,请参阅我对另一个问题的回答:Change theme like Fabric Web ( Default / Dark)