首页 > 解决方案 > Ionic 4. 如何更改旧 android 版本的标题背景颜色

问题描述

我尝试为此使用css变量

ion-toolbar {
  --background: #{$backgroundColor3};
  --min-height: #{$spacing * 5};
}

在最新的 chrome 和 android 8 上一切正常。但在带有 chrome 40.* 的 adnroid 5 上它不起作用。

我发现 Ionic 的最小 android 版本是 4.4文档

>ionic info
Ionic:

   Ionic CLI                     : 5.0.1
   Ionic Framework               : @ionic/angular 4.4.2
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.0.0, ios 5.0.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.0, (and 9 other plugins)

Utility:

   cordova-res : 0.3.0
   native-run  : 0.2.5

System:

   Android SDK Tools : 26.1.1 (C:\Android)
   NodeJS            : v11.14.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.9.0
   OS                : Windows 10

背景只是样式的一个问题:

来自 android 5 的问题的屏幕截图

来自 android 5 的问题的屏幕截图

普通截图

普通截图

标签: ionic-framework

解决方案


您需要在全局或页面 .scss 文件中使用添加

--background: var(--ion-color-primary);

这是你的答案。


推荐阅读