vue-this.$route.query和this.$route.params的使用例子
this.$route.query的使用router/index.js{path: '/mtindex',component: mtindex,//添加路由children: [{path: ':shopid',component: guessdetail}]},传参数thi...
·
this.$route.query的使用
- router/index.js
{
path: '/mtindex',
component: mtindex,
//添加路由
children: [{
path: ':shopid',
component: guessdetail
}]
},
- 传参数
this.$router.push({
path: '/mtindex/detail', query:{shopid: item.id}
});
- 获取参数
this.$route.query.shopid
- url的表现形式(url中带有参数)
http://localhost:8080/#/mtindex/detail?shopid=1
this.$route.params的使用
- router/index.js
{
path:'/mtindex',
component: mtindex,
//添加路由
children:[{
path:"/detail",
name:'detail',
component:guessdetail
}]
},
- 传参数( params相对应的是name query相对应的是path)
this.$router.push({
name: 'detail', params:{shopid: item.id}
});
- 获取参数
this.$route.params.shopid
- url的表现形式(url中没带参数)
http://localhost:8080/#/mtindex
更多推荐
已为社区贡献1条内容
所有评论(0)