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);
菜鸟自己的小记录,如有错请大佬纠错

浙公网安备 33010602011771号