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