A选项卡
在mounted里面使用window.addEventListener
监听是否调用localStorage
存储事件
mounted(){
var queryObject = Object.assign({ username: this.user.username }, this.pageParams, this.baseQueryForm);
queryObject.username = this.user.userId
window.addEventListener("storage", function(event){
this.loading = true;
taskTodoApi.list(queryObject).then(response => {
this.tableList = response.data.data;
this.total = response.data.total;
window.location.reload();// 强制刷新页面
}).finally(() => {
this.loading = false;
});
});
},
B选项卡
在b选项卡中任意方法或者生命周期函数中触发localStorage
存储事件
localStorage.setItem("refreshNum",'???sdfsdfad');
console.log(localStorage.getItem('refreshNum'))
delete localStorage.refreshNum
console.log(localStorage.getItem('refreshNum'))