項目中通過this.$router.push路由跳轉頁面傳遞參數的方式很常見,一般有兩種方式:
1.params傳參:
this.$router.push({name:'parasetEdit',params:{pk_refinfo:'test',value:'test1'}});
目標頁面接收參數:
this.$route.params.pk_refinfo
2.query傳參:
this.$router.push({path:'/uapbd/paraset/edit',query:{pk_refinfo:'test',value:'test1'}});
目標頁面接收參數:
this.$route.query.pk_refinfo
兩種方式的區別是query傳參的參數會帶在url后邊展示在地址欄,params傳參的參數不會展示到地址欄。需要注意的是接收參數的時候是route而不是router。兩種方式一一對應,名字不能混用。