Skip to content

Failed to pass Object data through named routes when migrating from vue-router 3.1.5 #494

@jackjtr

Description

@jackjtr

Version

4.0.0-beta.12

Reproduction link

https://codesandbox.io/s/affectionate-sunset-dng3r?fontsize=14&hidenavigation=1&theme=dark

Steps to reproduce

this.$router.push({
  name: `Target-Page`,
  params: {
    data: {
      fieldA: 'a',
      ...
      filedZ: false,
    }
})

What is expected?

this.$route.params?.data is supposed to be an Object data

What is actually happening?

this.$route.params?.data becomes a String data

data: "[object Object]"


Our projects are heavily using route.params to pass dynamic data from page to page.
We also tried "Passing Props to Route Components", which still cannot meet our demand.
We have to use JSON.stringify/JSON.parse/Number()/Boolean() everywhere to pass or retrieve dynamic data if this behaviour is correct for vue-router 4.x.

Looking forward to see a proper explanation.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions