首页
// 进入详情 detail(id){ console.log("详情") this.$router.push({path:‘./detail/‘+id}) }
详情页
methods:{ load(){ this.getDetail() console.log("路由的id") console.log(this.$route.params.id) this.detailId = this.$route.params.id } }
$router 和 $route的区别
$router是VueRouter的实例,在script标签中想要导航到不同的URL,使用$router.push方法。
返回上一个历史history用$router.to(-1)
$route为当前router跳转对象。里面可以获取当前路由的name,path,query,parmas
原文:https://www.cnblogs.com/ll15888/p/11585606.html