微信小程序版本提交更新版本 解决缓存问题

This commit is contained in:
lemon橪
2021-07-02 10:52:36 +08:00
parent 8ecc85a21c
commit efb2a7963e
5 changed files with 38 additions and 17 deletions

31
App.vue
View File

@@ -58,6 +58,10 @@ export default {
this.checkArguments(); // 检测启动参数
});
// #endif
// #ifdef MP-WEIXIN
this.applyUpdateWeChat();
// #endif
},
onShow() {
@@ -66,6 +70,33 @@ export default {
// #endif
},
methods: {
/**
* 微信小程序版本提交更新版本 解决缓存问题
*/
applyUpdateWeChat() {
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
});
updateManager.onUpdateReady(function (res) {
uni.showModal({
title: "更新提示",
content: "发现新版本,是否重启应用?",
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
}
},
});
});
updateManager.onUpdateFailed(function (res) {
// 新的版本下载失败
});
},
// TODO 开屏广告 后续优化添加
launch() {
try {