[踩坑]Vue2路由跳转使用params传递对象

247 阅读1分钟

一开始直接这样传

this.$router.push({ path: "/xx", obj })

但是传递过去打印出来是[object,object]

了解得知使用params传递对象需要将对象转为json,以字符串转递,再将其解析为对象。

this.$router.push({ path: "/xxx", query: { str } });
let x = JSON.parse(this.$route.query.str);