vue跳转传参方式
一、直接在路由中写参数<li v-for="article in articles" @click="getDescribe(article.id)">getDescribe(id) {//直接调用$router.push 实现携带参数的跳转this.$router.push({path: `/describe/${id}`,}...
·
一、直接在路由中写参数
<li v-for="article in articles" @click="getDescribe(article.id)">
getDescribe(id) {
// 直接调用$router.push 实现携带参数的跳转
this.$router.push({
path: `/describe/${id}`,
})
//在router--->index.js进行配置
{
path: '/describe/:id',
name: 'Describe',
component: Describe
}
//通过this.$route.prams.id取值
二、通过prams传参
this.$router.push({
name: 'Describe',
params: {
id: id
}
})
//在router--->index.js进行配置
{
path: '/describe',
name: 'Describe',
component: Describe
}
//通过this.$route.prams.id取值
三、通过query传参
this.$router.push({
path: '/describe',
query: {
id: id
}
//在router--->index.js进行配置
{
path: '/describe',
name: 'Describe',
component: Describe
}
//通过this.$route.query.id取值
作者:18fa100a8459
链接:https://www.jianshu.com/p/4debd60d3187
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
更多推荐
已为社区贡献12条内容
所有评论(0)