当前位置:网站首页>Uniapp wechat applet monitoring network
Uniapp wechat applet monitoring network
2022-07-07 08:48:00 【Du honeymoon】
/** * Judge whether there is a network */
export default function useNetWork() {
getNetStatus().then(res => {
console.log(' Have a net ', res);
}).catch(res => {
setTimeout(() => {
uni.showToast({
title: ' Please check your network connection ',
icon: 'none',
duration: 3000,
})
}, 100)
wx.onNetworkStatusChange(function(res) {
if (res.isConnected) {
uni.showToast({
title: ' The network has been restored ',
icon: 'none',
duration: 1000,
})
} else {
useNetWork();
}
})
})
}
function getNetStatus(){
return new Promise((resolve, reject) => {
wx.getNetworkType({
success (res) {
const networkType = res.networkType;
if (res.networkType === 'none') {
reject();
} else {
resolve();
}
}
})
})
}
Use :
// Call this method before requesting the interface
useNetWork();
边栏推荐
- ncs成都新電面試經驗
- You should use Google related products with caution
- Novice entry SCM must understand those things
- Required String parameter ‘XXX‘ is not present
- A bug using module project in idea
- leetcode135. Distribute candy
- Interpolation lookup (two methods)
- Golan idea IntelliJ cannot input Chinese characters
- [Yu Yue education] higher vocational English reference materials of Nanjing Polytechnic University
- JEditableTable的使用技巧
猜你喜欢

Opencv learning note 5 - gradient calculation / edge detection

国标GB28181协议视频平台EasyGBS新增拉流超时配置

Introduction to data fragmentation
![[Yu Yue education] basic reference materials of electrical and electronic technology of Nanjing Institute of information technology](/img/2a/01db1b84c26502c851786aaca56abe.jpg)
[Yu Yue education] basic reference materials of electrical and electronic technology of Nanjing Institute of information technology

ncs成都新電面試經驗

Analysis of using jsonp cross domain vulnerability and XSS vulnerability in honeypot

下载和安装orcale database11.2.0.4

Greenplum 6.x build_ install

Interpolation lookup (two methods)

Opencv learning note 3 - image smoothing / denoising
随机推荐
National standard gb28181 protocol video platform easygbs adds streaming timeout configuration
Quick sorting (detailed illustration of single way, double way, three way)
ncs成都新电面试经验
Opencv learning notes II - basic image operations
Introduction to data fragmentation
A single game with goods increased by 100000, and the rural anchor sold men's clothes on top of the list?
如何在快应用中实现滑动操作组件
AVL balanced binary search tree
POJ - 3616 Milking Time(DP+LIS)
数字三角形模型 AcWing 275. 传纸条
let const
How to add a mask of a target in a picture
如何在HarmonyOS应用中集成App Linking服务
Redis summary
Analysis of using jsonp cross domain vulnerability and XSS vulnerability in honeypot
[kuangbin]专题十五 数位DP
Exercise arrangement 2.10, 11
最长上升子序列模型 AcWing 1017. 怪盗基德的滑翔翼
【微信小程序:缓存操作】
Calling the creation engine interface of Huawei game multimedia service returns error code 1002, error message: the params is error