vue 监听路由变化
immediate:true //在组件初始化的时候也会执行handler处理函数
$route在这里不是函数,是对象
handle:当路由发生变化执行的操作
str中保存了路由,根据不同的路由,发起axios请求,对页面进行渲染
watch:{
$route:{
handler(){
console.log(this.$route.params.type);
var str=this.$route.params.type;
axios.get("getData.php",{params:{title:str}})
.then(function(res){
console.log(res.data)
})
},
immediate:true //在组件初始化的时候也会执行handler处理函数
}
}