對應(yīng)的路由配置模塊
,{
path: '/editCardetail',
name: 'editCardetail',
component: EditCardetail
}
1、使用$router.push 拼接參數(shù)傳參
this.$router.push('/editCardetail?editType=add')
其中editType=add即為傳遞的參數(shù)
2、 使用name來確定匹配的路由,通過params來傳遞參數(shù)
this.$router.push({
name: 'editCardetail',
params: {
editType: add
}
})
3、使用path來匹配路由,然后通過query來傳遞參數(shù)
this.$router.push({
path: '/editCardetail',
query: {
editType: add
}
})
注意:path不能與params一起使用,需要通過path來匹配路由的時候,使用query來傳參。
query要用path來引入,params要用name來引入,接收參數(shù)都是類似的,分別是this.route.query.name和this.route.query.name和this.route.query.name和this.route.params.name。
query更加類似于我們ajax中g(shù)et傳參,params則類似于post,前者在瀏覽器地址欄中顯示參數(shù),后者則不顯示。