vue中监听路由传过来的参数是否发生变化

// 首先第一次进入该页面
mounted(){
    this.articalType = this.$route.query.artical_type;
    this.getArticalByType();
},

...

// 改变参数且不刷新页面
watch:{
    // 监听参数是否发生变化
    $route: {
        handler() {
            this.articalType = this.$route.query.artical_type;
            this.getArticalByType();
        },
        //深度监听,同时也可监听到param参数变化
        deep: true,
    }
  }
发布了69 篇原创文章 · 获赞 20 · 访问量 9766

猜你喜欢

转载自blog.csdn.net/qq_41980461/article/details/104528585