vue 點擊一條消息跳轉相應的頁面且對應相應的大模塊和辦理狀態


需求:點擊一條消息跳轉相應的頁面且對應相應的大模塊和辦理狀態為選中狀態

問題描述:點擊一條消息后將需要改變的參數拼接到url地址中跳轉到A頁面,當將參數賦值給辦理狀態時頁面辦理狀態不改變

解決:使用watch監聽屬性監聽url變化 && 給url加時間戳(防止緩存url沒有改變watch監聽不到)

消息列表中點擊事件中:

handleRead (item, index) {
        let status = item.status
        let business_code = item.business_code
        let getTimestamp=new Date().getTime(); //加時間戳防止url沒有改變watch監聽不到 this.$router.push({
          path:`/regulation/xzsp?status=${status}&business_code=${business_code}+${getTimestamp}`
        })
        this.$emit('handle-hide')
}

A頁面中:

watch:{
      $route(to, from) { // watch屬性監聽路由變化 this.activeNameFn()
      }
},
methods:{
      activeNameFn(){
        if(this.$route.query.status!=undefined){
          this.activeName = this.$route.query.status
          this.business_code = this.$route.query.business_code
          console.log(this.activeName,'router')
        } else {
          this.activeName = 'DJ'
          console.log(this.activeName,'11')
        }
        console.log(this.activeName)
      },
}

 


免責聲明!

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



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