最近暗黑模式成为了潮流,微信小程序也推出了暗黑模式适配,下面来记录一个下适配暗黑模式。
效果图:
一、实现
1、开启暗黑模式
在 app.json 中配置 "darkmode": true
// app.json
{
...
"darkmode": true
}
2、配置主题文件
在根目录新建主题配置文件 theme.json, 并在 app.json 中配置路径引入
// app.json
{
...
"themeLocation": "theme.json"
}
theme.json配置文件一共分为两个属性,light 和 dark,分别正常模式和暗黑模式。
theme.json 示例如下(仅供参考):
// theme.json
{
"light": {
"navBackgroundColor": "#ffffff",
"navTextStyle": "black"
},
"dark": {
&