使用localStorage,进入修改页面,设置localstorage,跳转回筛选页面时,监听route,判定设置localStorage是否是具体的值,如果是,不清空筛选条件,否则清空,最后把删除设置的localstorage。
具体操作如下:
修改页面是modify.vue
created () { const sign = ‘modify‘ localStorage.setItem(‘signs‘, sign) }
筛选页面是a.vue
‘$route‘: function (to) { if (to.name === ‘A‘) { const z = localStorage.getItem(‘signs‘) if (z === ‘modify‘) { //移除设置的localstorage localStorage.removeItem(‘signs‘) } else { //清空筛选条件 } } }
原文地址:https://www.cnblogs.com/jiaxiaonuo/p/10514943.html
时间: 2024-10-07 19:16:53