首页 > 其他 > 详细

动态路由

时间:2019-09-25 18:27:09      阅读:135      评论:0      收藏:0      [点我收藏+]

首页

    // 进入详情
        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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!