vue路由跳轉之當前頁面路由跳轉並動態改變頁面的title


改之前:

 

 然后在保證不跳轉到其他頁面,在本頁面中進行路由跳轉,實現title的變更

 改之后:

 在當前頁面就實現了title的動態改變。

下邊是實現的方法:

在點擊下一步的時候:

 動態添加url並且攜帶自己改的參數,並存儲一下當前頁面的值。

location.href = `/insurantImportantChange?showPopup=true&&policyNo=`+`${this.policyNo}`
localStorage.setItem('info',JSON.stringify(this.info))
localStorage.setItem('oldInfo',JSON.stringify(this.oldInfo))

然后,“頁面跳轉”也就是頁面的刷新,再在create方法里面寫條件判斷

    if (this.$route.query.showPopup == 'true') {
      this.info = JSON.parse(localStorage.getItem('info'))
      this.oldInfo = JSON.parse(localStorage.getItem('oldInfo'))
      this.showPopup = true
      // this.showPopup = false
      document.title = '被保人重要信息變更確認'
      console.log(this.policyNo,'Klay')
    }else if(this.$route.query.showPopup == 'false'){
      this.info = JSON.parse(localStorage.getItem('backInfo'))
      this.oldInfo = JSON.parse(localStorage.getItem('oldInfo'))
      this.showPopup = false
      // this.showPopup = false
      document.title = '被保人重要信息變更'
      console.log(this.policyNo,'Klay')
    } else {
      document.title = '被保人重要信息變更'
      this.showPopup = false
      this.getInfo()
    }

在第二個界面中有個"返回修改",在跳到原來的頁面,同樣要進行存儲數據

 this.showPopup = !this.showPopup
 localStorage.setItem('backInfo',JSON.stringify(this.info))
 console.log(JSON.parse(localStorage.getItem('backInfo')),'00000')
 location.href = `/insurantImportantChange?showPopup=false&&policyNo=`+`${this.policyNo}`

到這兒,也就實現這個需求了。

 


免責聲明!

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



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