vue页面刷新页面数据不在的问题

vue页面刷新页面数据不在的问题

vue页面跳转通过parmas携带的参数在新页面里一刷新就会丢失,
1.使用sessionStorage保存页面要用到的数据无论页面怎么刷新数据都不会丢失
传参数的页面设置


    xiang(row) {
      this.id = row;
      //把页面要传的参数存到sessionStorage里面
      sessionStorage.setItem("id", this.id);
      //   console.log(row); //此时就能拿到整行的信息
      this.$router.push({
        name: "newsdetail",
        params: {
          id: this.id
        }
      });
    },

新打开的页面取出来

created() {
    // this.id = this.$route.params.id;
    //从sessionStorage把页面要用的参数取出来
    this.id = sessionStorage.getItem("id");
    // sessionStorage.clear("id");
    //页面加载要用到的方法
    this.pagination();
  },

猜你喜欢

转载自blog.csdn.net/qq_41241767/article/details/90644421