위챗 소프로그램 온라인 버전 자동 업데이트 함수
1380 단어 독학 노트
onLoad: function () {
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
//
// console.log('hasUpdate', res.hasUpdate)
})
updateManager.onUpdateReady(function () {
wx.showModal({
title: ' ',
content: ' , ?',
success: function (res) {
if (res.confirm) {
// , applyUpdate
updateManager.applyUpdate()
}
}
})
})
updateManager.onUpdateFailed(function () {
//
})
}, 쓰기 2:
onLoad: function () {
this.updateManager()
}
/**
*
*/
updateManager() {
if (!wx.canIUse('getUpdateManager')) {
return false;
}
const updateManager = wx.getUpdateManager();
updateManager.onCheckForUpdate(function (res) {
});
updateManager.onUpdateReady(function () {
wx.showModal({
title: ' ',
content: ' , ',
showCancel: false,
success(res) {
if (res.confirm) {
updateManager.applyUpdate()
}
}
});
});
updateManager.onUpdateFailed(function () {
wx.showModal({
title: ' ',
content: ' ',
showCancel: false
})
});
},