小程序
小游戏
企业微信
微信支付
扫描小程序码分享
代码审核成功提交发布之后,进入小程序还是展示的原来的版本代码,必须删除之后再重新添加才会展示新的版本代码,请问有没有什么办法能直接更新?这样对用户来说是不合理的,他们不知道要进行这个操作呀,求指点
2 个回答
你好,建议参阅小程序的运行机制文档更新.小程序
内容中可能包含密钥、AppSecret等私密参数,泄漏会有安全风险,请检查内容并确认。
我已经帮你写好了,
//检查微信小程序是否最新版本
checkForUpdate: function () {
const updateManager = wx.getUpdateManager()
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function (res) {
if (res.confirm) {
updateManager.applyUpdate()
}
})
updateManager.onUpdateFailed(function () { })
},
将此函数放到app.js中,在
onLaunch
this.checkForUpdate()
中调用即可
你好,建议参阅小程序的运行机制文档更新.小程序
我已经帮你写好了,
//检查微信小程序是否最新版本
checkForUpdate: function () {
const updateManager = wx.getUpdateManager()
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function (res) {
if (res.confirm) {
updateManager.applyUpdate()
}
}
})
})
updateManager.onUpdateFailed(function () { })
},
将此函数放到app.js中,在
onLaunch
this.checkForUpdate()
中调用即可