微信小程序 uni-app解决旧页面缓存问题

微信小程序在迭代版本后,若未清除原有缓存,显示的还是旧版,加入下述代码可解决这个问题

在common.js文件中加入

mpUpdate() {
		const updateManager = wx.getUpdateManager() // 小程序版本更新管理器
		updateManager.onCheckForUpdate(function (res) {
		  // 请求完新版本信息的回调
		})	
		updateManager.onUpdateReady(function () {     
		    // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
		    updateManager.applyUpdate()
		      	  
		})	
		updateManager.onUpdateFailed(function () {
		  // 新版本下载失败
		})	       
	},

在app.vue中调用

this.$common.mpUpdate();

你可能感兴趣的:(微信小程序,微信小程序,uni-app,前端)