我正在使用javascript在ASP.net MVC应用程序中工作。我正在使用devExpress dxSwitch尝试更改页面的主题。DevExpress获取样式表添加变量
我在我的_layout.cshtml的头这段代码
@Html.DevExpress().GetStyleSheets("dark",
new StyleSheet { ExtensionSuite = ExtensionSuite.NavigationAndLayout },
new StyleSheet { ExtensionSuite = ExtensionSuite.Editors },
new StyleSheet { ExtensionSuite = ExtensionSuite.GridView },
new StyleSheet { ExtensionSuite = ExtensionSuite.Dashboard}
)
而不是硬编码在我想看看我是否能代替它使用一个变量,并应用了主题为“暗”这个功能可以在明暗之间切换。
$('#switch').click(function() {
var whichTheme = $("#switch").dxSwitch("instance");
var valueSwitch = whichTheme.option("value");
if (valueSwitch === true) {
$('body').css('background-color', '#343434');
} else {
$('body').css('background-color', 'whitesmoke');
}
});