码迷,mamicode.com
首页 > 其他好文 > 详细

编程式路由

时间:2018-01-16 14:00:48      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:method   eth   区别   div   path   ram   query   ***   param   

编程式路由
         通过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);
             }
           }

编程式路由

标签:method   eth   区别   div   path   ram   query   ***   param   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!