分享好友 教程首页 教程搜索 频道列表

前端列表页进入详情页返回时保留上次列表页的数据

2022-04-03 17:061890
+关注2
核心提示:转载,未测试
//本地存储
<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>


本文标签: #位置 #列表 #返回 #上一页
整理员:网络转载
免责声明:凡注明来源本网的所有作品,均为本网合法拥有版权或有权使用的作品,欢迎转载,注明出处。非本网作品均来自互联网,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。
生成海报
您可能在找更多

网站总后台的工作便笺和会员的商务中心商务便签的保存位置路径

    这个是按会员id自动建立文件目录的,位置放在file/user/里,如总管理员的是file/user/1/1/note.php

小黑 destoon设置相关2023-02-01

js返回到上个页面之后,滚动条还在上次的地方

    转载的,未测试

网络转载 JavaScript教程2022-04-03

html 列表页滚动后跳转,返回时停留在原来位置

    未测试,转载的

网络转载 JavaScript教程2022-04-03

滚轮滚动到某位置时指定div改变定位属性

    1、offset() 方法返回或设置匹配元素相对于文档的偏移

网络 JS相关2021-04-10

实现页内跳转定位到某个ID

    实现页内跳转定位到某个ID

小黑 web前端开发2020-02-26

下一篇
我来说两句
抢沙发