function checkNew(){ const updateManager = uni.getUpdateManager() updateManager.onCheckForUpdate(function (res) { // 请求完新版本信息的回调 }) updateManager.onUpdateReady(function () { uni.showModal({ title: '更新提示', content: '新版本已经准备好,立即重启应用?', showCancel: false, success: function (res) { if (res.confirm) { updateManager.applyUpdate(); } } }) }) updateManager.onUpdateFailed(function () { uni.showModal({title: '温馨提示',content: '新版本下载失败,请卸载小程序再重试',showCancel: false}); }) } export default function init(){ uni.getNetworkType({ success: res => { const { networkType } = res; if (!['none'].includes(networkType)) { // 检查小程序更新 checkNew() }else{ uni.showToast({ title: '当前无网络访问,请开启网络', icon: 'none' }) } }, fail: () => { uni.showToast({ title: '获取网络失败,网络不稳定', icon: 'none' }) } }) }