Vue.js 如何通过Vue路由器直接在道具中传递对象?

Vue.js 如何通过Vue路由器直接在道具中传递对象?,vue.js,vue-router,vuejs3,Vue.js,Vue Router,Vuejs3,在Vue JS3(我的Vue组件)中,我可以传递这样的道具:Parent: <script> export default { data() { return { links: [], }; }, methods: { editLink(el) { this.$router.push({ name: "EditLink", params: { id: el.id,

在Vue JS3(我的Vue组件)中,我可以传递这样的道具:Parent:

<script>
export default {
data() {
    return {
    links: [],
    };
},
methods: {
    editLink(el) {
    this.$router.push({
        name: "EditLink",
        params: {
        id: el.id,
        short_link: el.short_link,
        long_link: el.long_link,
        },
    });
    },
},
};
</script>

当我试图打印出来时,我得到的elem值是[Object Object],而不是实际对象。为什么会这样?解决方案是什么?

尝试分散
el
,而不是将每个值分配给相应的键:

    this.$router.push({
        name: "EditLink",
        params: {...el},
    });
然后在目标页面中:

mounted() {
    this.link = {...this.$route.params};
},
    this.$router.push({
        name: "EditLink",
        params: {...el},
    });
mounted() {
    this.link = {...this.$route.params};
},