vue监听url路由传递参数变化

**A.页面传递参数**
 Clickcity(){
    
    
        this.$router.push({
    
    path:'/City',query:{
    
    
         url:12
       }})
      },
 **B.页面监听接收参数**
 watch: {
    
    
// 监听到路由地址的改变
  $route:{
    
    
   immediate:true,
    handler(){
    
    
     if(this.$route.query.url){
    
    
        console.log(1212)
       }
     }
  }
}

猜你喜欢

转载自blog.csdn.net/weixin_43959276/article/details/111298173