首页 > Windows开发 > 详细

[PWA] Check Online Status by using the NavigatorOnLine API

时间:2018-07-02 21:13:38      阅读:177      评论:0      收藏:0      [点我收藏+]

Even if you have your application fully cached, you couldn’t perform any external request without internet connection. That’s why in order to build an offline-capable application, you must know when it’s actually offline.

This lesson shows you how to use the NavigatorOnLine API and online/offline events in order to disable the functionality to send messages of the application.

 

    this.online = navigator.onLine
    window.addEventListener(‘online‘, () => (this.online = true))
    window.addEventListener(‘offline‘, () => {
      this.online = false
    })

 

[PWA] Check Online Status by using the NavigatorOnLine API

原文:https://www.cnblogs.com/Answer1215/p/9255725.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!