模拟器和 web 本地主机的 Ionic 不同样式

Ionic different styles for emulator and web localhost

我对浏览器有不同的看法,emulator.I 认为 css 代码目前除了浏览器外无法工作。

例如,我更改了 -ion-background-color: 用于 .md body 和 iosbody。但是模拟器也显示默认主题:

请多多指教?

我正在使用 Ionic 5 和如下配置:

ionic (Ionic CLI)             : 4.12.0 (C:\Users\hckav\node_modules\ionic)
Ionic Framework               : @ionic/angular 5.0.7
@angular-devkit/build-angular : 0.803.26
@angular-devkit/schematics    : 8.3.26
@angular/cli                  : 8.3.26
@ionic/angular-toolkit        : 2.2.0

电容器:

capacitor (Capacitor CLI) : 2.0.1
@capacitor/core           : 2.0.1

系统:

NodeJS : v12.14.1 (C:\Program Files\nodejs\node.exe)
npm    : 6.14.4
OS     : Windows 10

当您在 iOS 或 Android 上将应用构建到 运行 时,这些 class 会自动添加到 body 标签中。

iOS: <body class="platform-ios">

Android: <body class="platform-android">

网站:<body class="platform-browser">

这就是它们不同的原因。你可以将你的 class 动态添加到你的 body 标签来解决它