<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>
网友评论