美文网首页
vue路由监听

vue路由监听

作者: 程序猿的小生活 | 来源:发表于2023-02-02 14:52 被阅读0次
    <template>
    <div>
        <keep-alive>
            <router-view/>
            </keep-alive>
        </div>
        
    </template>
    <script>
        export default{
            created() {
                //this.$router.push("/hw")
                },
                watch:{
                    $route(to,from){//注意:监听代码必须放在<router-view/>页面中才起作用
                        alert(to.path)
                        alert(from.path)
                    }
                }
            
        }
    </script>
    
    

    相关文章

      网友评论

          本文标题:vue路由监听

          本文链接:https://www.haomeiwen.com/subject/ajawhdtx.html