首页 > 其他 > 详细

编程式路由

时间:2018-01-16 13:35:04      阅读:219      评论:0      收藏:0      [点我收藏+]

编程式路由
         通过js实现也面跳转
         $router.push(‘name‘)
         $router.push({path:‘name‘})
         $router.push({path:‘name?a=123‘})或者$router.push({path:‘name‘,query:{a:123}})
         $router.go(1)


         ****页面获取值得区别
         1)<span>{{$route.params.testId}}</span>
            由:
            routes:[
               {
                 path:‘/goods/:testId‘
                 ...
               }
            ]

        2) <span>{{$route.query.testId}}</span>

           由:
           methods{
             eg(){
               this.$router.push(path:‘/goods?a=123‘);
                 //this.$router.push(‘/cart‘);
                //this.$router.push({path:‘/cart?cartId=123‘})
                //this.$router.push({path:‘/cart‘,query:{cartId:123}})  cartId写不写单引号都行
                this.$router.go(-2);
             }
           }

编程式路由

原文:https://www.cnblogs.com/lmxxlm-123/p/8295805.html

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