search

Home  >  Q&A  >  body text

angular.js - The angularjs framework used in WeChat public account development, how to monitor network status in real time and prevent $http requests when the network is disconnected

Use angular to develop public accounts and use the $http service to access data. However, in the WeChat test, when the network is disconnected, the $http request is still executed and the error page jumps ( Because the interceptor is set up, when $http does not respond or the response fails, my custom interceptor will cause the page to jump. Go to a custom error page ) instead of prompting: wifi and mobile data disconnected , when the request is a normal http://www.baidu. com link, WeChat can prompt: WiFi and mobile data have been disconnected. How can I intercept the $http request and prompt correctly after the network is disconnected? Thank you

PHPzPHPz2768 days ago1504

reply all(1)I'll reply

  • 習慣沉默

    習慣沉默2017-05-15 17:12:15

    You can prompt based on the status code returned by the http request, such as 404, 500, etc. to switch to different prompt pages

    reply
    0
  • Cancelreply