<noframes id="7xbfr"><pre id="7xbfr"><output id="7xbfr"></output></pre>

      <big id="7xbfr"><font id="7xbfr"><listing id="7xbfr"></listing></font></big>
        <p id="7xbfr"></p>
        <menuitem id="7xbfr"></menuitem>

          <video id="7xbfr"><mark id="7xbfr"><listing id="7xbfr"></listing></mark></video>
            <form id="7xbfr"></form>

          <delect id="7xbfr"><var id="7xbfr"></var></delect>

          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);
            }
            }


          黄网站免费 <