//檢查微信小程序是否最新版本
? ??????checkForUpdate: function() {
????????????????????const updateManager = wx.getUpdateManager()
????????????????????updateManager.onUpdateReady(function() {
????????????????????????????????wx.showModal({
????????????????????????????????????????????title: '更新提示',
????????????????????????????????????????????content: '新版本已經(jīng)準(zhǔn)備好,是否重啟應(yīng)用?',
????????????????????????????????????????????success: function(res) {
????????????????????????????????????????????????????????if (res.confirm) {
????????????????????????????????????????????????????????????????????updateManager.applyUpdate()
????????????????????????????????????????????????????????????}
????????????????????????????????????????????}
????????????????????????????????})
????????????????????})
????????};
將此函數(shù)放到app.js中,在
onLaunch
this.checkForUpdate()
中調(diào)用即可