编程式路由

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

posted @ 2018-01-16 11:47  豆豆飞  阅读(238)  评论(0编辑  收藏  举报