监测路由变化

224 阅读1分钟
  watch: {    // 当点击查看下级时,公用得是同一个页面,所以监测路由变化,获取级别num和id    $route(val, oldval) {      this.rank =        typeof val.query.num === 'undefined' ? 1 : parseInt(val.query.num)      this.id_s = val.query.id      this.options[1].value = this.rank      if (val) {        this.getList()      }    }  },
 mounted() {    // 当返回得时候可以路由参数里面获取级别和id    if (this.$route.query.num) {      this.rank = this.$route.query.num      this.options[1].value = this.rank    }    if (this.$route.query.id) {      this.id_s = this.$route.query.id    }    this.getList()  },