关于浏览器的PWA模式

发布时间 2023-06-12 14:48:49作者: 河畔的风

浏览器的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) });