在 Chrome Android 中全屏运行的 PWA 不支持显示模式:独立

gan*_*nar 3 android google-chrome vue.js progressive-web-apps

standalone用于在 Chrome Android 中检测模式的方法在我的 PWA 中均不起作用

这是我尝试过的CSS方法

@media all and (display-mode: standalone) {
    /* Here goes the CSS rules that will only apply if app is running standalone */
}
Run Code Online (Sandbox Code Playgroud)

这是 Javascript 方法(第 171-175、297-306 行)

function isRunningStandalone() {
    return (window.matchMedia('(display-mode: standalone)').matches);
}
...
if (isRunningStandalone()) {
    /* This code will be executed if app is running standalone */
}
Run Code Online (Sandbox Code Playgroud)

它们都不起作用:isRunningStandalone()在 Chrome Android 中进行远程测试会返回false,尽管该示例有效。

(这里是 @josemmo 制作的示例)

我已经在 iOS 和 3 部不同的 Android 手机中测试了代码。iOS 运行完美。

gan*_*nar 5

我找到了问题的解决方案:manifest.json必须有"display": "standalone"

"display": "fullscreen"不管用。我也无法测试它。