一、将数据放在本地缓存:
window.sessionStorage.setItem("tempList", JSON.stringify(res.result));router.push(url)
二、并取出、删除操作:
//取出
const tempList: any = ref({})tempList.value = window.sessionStorage.getItem('tempList')
三、以及监听用户刷新操作,在刷新之前删除缓存的数据:```htmlwindow.addEventListener("beforeunload", function (e) {tempList.value = {}window.sessionStorage.removeItem('tempList')console.log('删除缓存数据:', tempList.value)});
如果觉得《vue3将数据放在本地缓存 并取出 删除操作 以及监听用户刷新操作。》对你有帮助,请点赞、收藏,并留下你的观点哦!