檢測(cè)小程序版本更新
App.vue 入口文件中 添加如下代碼文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-727609.html
//檢測(cè)小程序版本是否更新
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function(res) {
// 請(qǐng)求完新版本信息的回調(diào)
console.log(res)
})
//更新版本
updateManager.onUpdateReady(function() {
wx.showModal({
title: '更新提示',
content: '新版本已經(jīng)準(zhǔn)備好,是否重啟應(yīng)用?',
success(res) {
if (res.confirm) {
// 新的版本已經(jīng)下載好,調(diào)用 applyUpdate 應(yīng)用新版本并重啟
updateManager.applyUpdate()
}
}
})
})
updateManager.onUpdateFailed(function () {
// 新版本下載失敗
})
uni.getStorageSync('')
-
微信小程序 測(cè)試
-
重新編譯后 即可看到以下內(nèi)容
關(guān)閉全局打印
在main.js中 加上以下代碼文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-727609.html
// 上線(xiàn)后全局關(guān)閉console.log打印
if (uni.getSystemInfoSync().platform !== "devtools") {
console.log = () => {};
console.info= () => {};
}
到了這里,關(guān)于uni.app如何檢測(cè)小程序版本更新以及上線(xiàn)后如何關(guān)閉全局打印的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!