watch監聽路由信息

watch函數中監聽$route

 watch: {
    $route(to, from) {
      // console.log("to");
      // console.log(to);
      // console.log("from");
      // console.log(from);
      // console.log("this.$route.path");
      // console.log(this.$route.path);
      this.defaultActive = to.path;
    }
  }

參數解釋

to表示將當前所在路由信息, from表示從哪跳轉到路由信息

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章