方式一。
pages.json:
"globalStyle" : {"navigationBarTextStyle" : "black","navigationBarTitleText" : "uni-app","navigationBarBackgroundColor" : "#F8F8F8","backgroundColor" : "#F8F8F8","app-plus" : {"titleNView" : false,"softinputMode": "adjustResize"},"disableScroll": true // 禁用舊版頁面緩存},
方式二。
在?App.vue
?的?onLaunch
?中添加:
onLaunch() {// 版本變更檢測const currentVersion = plus.runtime.version;const lastVersion = uni.getStorageSync('app_version');if (!lastVersion || lastVersion !== currentVersion) {// 關鍵操作:清除WebView緩存const webview = plus.webview.currentWebview();if (webview) {webview.clear(); // 清除當前WebView緩存}// 清除應用緩存plus.cache.clear();// 強制重啟(關鍵!)setTimeout(() => {plus.runtime.restart();}, 500);// 存儲新版本uni.setStorageSync('app_version', currentVersion);}
}