1.query方式:
(注意:path要用‘/’+跳轉頁的名字)
傳出頁多傳一個query對象
data(){
return{
var a = '123'
}
A(){
this.$router.push({
path: '/跳轉頁的名字',
query: {
id: id
value:this.a
}
})
}
接收頁直接用 this.$route.query.屬性名
就可以拿到了(注意是route不是router):
this.$route.query.id
this.$route.query.value
2.params方式:
(注意:name直接+跳轉頁的名字,不用‘/’)
傳出頁多傳一個params對象
data(){
return{
var b = '123'
}
}
B(){
this.$router.push({
name: '跳轉頁的名字',
params: {
id: id
value:this.b
}
})
}
接收頁直接用 this.$route.params.屬性名
就可以拿到了(注意是route不是router):
this.$route.params.id
this.$route.params.value