vue 路由传参为对象时如何处理?

通过转换传递json字符串来实现传递,接收时再转换回来。

传递时代码:

let strItem = JSON.stringify(item);
this.$router.push(`/detail/` + encodeURIComponent(strItem));

 接收时的处理:

 let info = decodeURIComponent(this.$route.params.id);
 this.detail= JSON.parse(info);

  

  

posted @ 2020-10-22 14:25  络角阔落  阅读(3401)  评论(0)    收藏  举报