module.exports = { update: update } var isShowed = false; //检测版本是否更新 function update() { if (isShowed) { return; } //检测版本更新 const manager = wx.getUpdateManager(); //检测版本是否更新 manager.onCheckForUpdate(function (e) { }); //版本更新 manager.onUpdateReady(function (e) { isShowed = true; wx.showModal({ title: '已有新版本咯', content: '请您删除当前小程序,重新打开呦~', success: function (res) { if (res.confirm) { manager.applyUpdate(); } } }); }); //版本更新失败 manager.onUpdateFailed(function (e) { }); };