寫在uniapp的APP.vue的onShow方法中文章來源:http://www.zghlxwxcb.cn/news/detail-446443.html
uni.onNetworkStatusChange(function(res) {
?? ??? ??? ??? ?if (res.isConnected) {
?? ??? ??? ??? ??? ?uni.showModal({
?? ??? ??? ??? ??? ??? ?title: '系統(tǒng)提示',
?? ??? ??? ??? ??? ??? ?content: '當(dāng)前設(shè)備網(wǎng)絡(luò)已恢復(fù)',
?? ??? ??? ??? ??? ??? ?showCancel: false,
?? ??? ??? ??? ??? ??? ?confirmText: '知道了'
?? ??? ??? ??? ??? ?})
?? ??? ??? ??? ?} else {
?? ??? ??? ??? ??? ?uni.showModal({
?? ??? ??? ??? ??? ??? ?title: '系統(tǒng)提示',
?? ??? ??? ??? ??? ??? ?content: '當(dāng)前設(shè)備無網(wǎng)絡(luò)或網(wǎng)絡(luò)較差',
?? ??? ??? ??? ??? ??? ?cancelText: '取消',
?? ??? ??? ??? ??? ??? ?confirmText: '確定',
?? ??? ??? ??? ??? ??? ?success: (res) => {
?? ??? ??? ??? ??? ??? ??? ?if (res.confirm) {
?? ??? ??? ??? ??? ??? ??? ??? ?uni.reLaunch({
?? ??? ??? ??? ??? ??? ??? ??? ??? ?url:'/pages/index/index'
?? ??? ??? ??? ??? ??? ??? ??? ?})
?? ??? ??? ??? ??? ??? ??? ?} else {
?? ??? ??? ??? ??? ??? ??? ??? ?// #ifdef H5
?? ??? ??? ??? ??? ??? ??? ??? ?uni.navigateTo({
?? ??? ??? ??? ??? ??? ??? ??? ??? ?url:'/pages/index/login'
?? ??? ??? ??? ??? ??? ??? ??? ?})
?? ??? ??? ??? ??? ??? ??? ??? ?// #endif
?? ??? ??? ??? ??? ??? ??? ??? ?// #ifdef APP-PLUS
?? ??? ??? ??? ??? ??? ??? ??? ?plus.runtime.quit()
?? ??? ??? ??? ??? ??? ??? ??? ?// #endif
?? ??? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?})
?? ??? ??? ??? ?}文章來源地址http://www.zghlxwxcb.cn/news/detail-446443.html
到了這里,關(guān)于uniapp 安卓端實(shí)時(shí)監(jiān)聽網(wǎng)絡(luò)狀態(tài)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!