vue 分頁跳轉頁面詳情,返回記住當前點擊第幾頁


列表頁

mounted 調用:

 

mounted() {
    this.getSchoolWebModuleMessageListFunc();
  },

 

methods中,定義:

getSchoolWebModuleMessageListFunc(){
    //當從詳情頁返回的時候,先獲取詳情頁中存下來的detall標識,在列表頁中,把獲取到的分頁頁碼重新賦值賦值,用以返回前的頁面,保持不變 if(sessionStorage.getItem('detail')){ // console.log(Number(sessionStorage.getItem("currentPage"))); //如果有這個就讀取緩存里面的數據 this.pageNo=Number(sessionStorage.getItem("currentPage")); this.currentPage4 = Number(sessionStorage.getItem("currentPage")); }else{ this.pageNo=1; //這個主要是從其他頁面第一次進入列表頁,清掉緩存里面的數據 sessionStorage.removeItem("currentPage"); } }

在分頁的 handleCurrentChange 中,點擊切換分頁頁碼,獲取當前點擊的是第幾頁:

handleCurrentChange(val) {
      // console.log(val);
      this.pageNo = val;
      sessionStorage.setItem('currentPage',val);
    }

  離開頁面時候,清除:

destroyed(){
    sessionStorage.removeItem("detail");
  },

詳情頁:

初始化數據的時候,設置標識: sessionStorage.setItem("detail",true);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM