<template>
<div class="content">
<web-view ref="webview" :src="title"></web-view>
</div>
</template>
<script>
export default {
data() {
return {
title: 'http://www.baidu.cn/' // 你可以根据需要替换成你的URL
};
},
mounted() {
// 在应用启动时清除本地缓存
this.clearAppCache();
},
methods: {
clearAppCache() {
if (uni.getSystemInfoSync().platform === 'android') {
// 调用plus.runtime原生方法清理缓存
plus.cache.clear(() => {
console.log('缓存已清除');
this.reloadWebView();
}, (error) => {
console.error('清除缓存失败: ', error);
});
} else {
console.log('当前平台不是安卓设备,未执行清理缓存操作');
}
},
reloadWebView() {
this.$refs.webview.reload(); // 重新加载webview
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
height: 100%;
}
</style>
uniapp 使用web-view 来套地址实现分离式打包
猜你喜欢
转载自blog.csdn.net/qq_44759522/article/details/142765825
今日推荐
周排行