关于浏览器的PWA模式

河畔的风 / 2023-06-12 / 原文

浏览器的PWA模式是一种可安装(Installable), 可以出现在设备的主屏幕。

关于开发如何识别PWA模式

    const isInStandaloneMode = () => (window.matchMedia('(display-mode: standalone)').matches) 
                                    || (window.navigator.standalone)
                                    || document.referrer.includes('android-app://');     //切换到pwa模式的时候可以用来识别 window.matchMedia('(display-mode: standalone)').addEventListener('change', ({ matches }) => { setTitle(matches) });