<thead id="rrjt3"></thead>
      <progress id="rrjt3"><dfn id="rrjt3"></dfn></progress>

      <em id="rrjt3"></em>

        <address id="rrjt3"><ins id="rrjt3"><dfn id="rrjt3"></dfn></ins></address>
          <i id="rrjt3"></i>

        watch監聽路由變化詳解

        時間:2021-09-14 11:20:17 類型:vue
        字號:    

          一、watch監聽路由的方法

          通過watch監聽,當路由發生變化的時候執行。

          方法一:

        watch:{
          $router(to,from){
               console.log(to.path)
          }
        }

          方法二:

        watch: {
           $route: {
             handler:  function (val, oldVal){
               console.log(val);
             },
             // 深度觀察監聽
             deep:  true
           }
        },

          方法三:

          watch: {
          '$route' : 'getPath'
          },
          methods: {
          getPath(){
          console.log( this .$route.path);
          }
          }


        黄网站免费 <