//本地存儲
<scriopt>
//根據路由守衛來判斷是從哪個頁面進入此頁面的
beforeRouteEnter(to, from, next) {
if (from.path == "/recruitment/detail") {
sessionStorage.setItem("getInitInfoFlag", "true");
next();
} else {
sessionStorage.setItem("getInitInfoFlag", "false");
next();
}
},
created(){
const getInitInfoFlag = sessionStorage.getItem("getInitInfoFlag");
if (getInitInfoFlag === "true") {
const searchInfo = JSON.parse(sessionStorage.getItem("searchInfo"));
this.limit = searchInfo.limit;
this.page = searchInfo.page;
this.name= searchInfo.name;
this.age= searchInfo.age;
......
} else {
sessionStorage.removeItem("searchInfo");
}
this.init()
},
method:{
//初始化頁面
init(){
......
},
//進入詳情頁面
goDetail(){
let searchInfo={
page:this.page,
limit:this.limit,
name:this.name,
age:this.age,
......
}
//保存起來
sessionStorage.setItem("searchInfo", JSON.stringify(searchInfo));
this.$router.push({
path:'詳情路由',
query:{
//傳的參數
}
})
}
}
</scriopt>