【vue】 携带对象参数跳转页面

1.携带对象

json转字符串后进行编码

<span slot="action" slot-scope="record" ref="action">
         <a-button type="link" @click="$router.push({name:'editSonAccount',query: { record: 
          encodeURIComponent(JSON.stringify(record)) }})">
                    编辑
         </a-button>
</span>

2.接收对象

在mounted钩子中获取并判断

//mounted钩子中调用该方法
handleForm(){
   let record = this.$route.query.record;
   if(roleRecord){
       this.form = JSON.parse(decodeURIComponent(record));
   }
            
},

猜你喜欢

转载自blog.csdn.net/THcoding_Cat/article/details/113695789