vue中watch监听路由传来的参数变化

395 阅读1分钟
A页面:  
this.$router.push({ name: "Result", query: { // 发送搜索词给result title: this.inputVal, },
B页面:
watch: {
    // 监视变化
    "$route.query.keyWord": {
      immediate: true,
      handler() {
        this.paramlist.keyWord = this.$route.query.keyWord;
        this.getProductist(this.paramlist);
      },
    },
  },