Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should the type of $route.query.xx be unified into a String type? #2471

Closed
zhangzhengyi12 opened this issue Nov 8, 2018 · 3 comments
Closed

Comments

@zhangzhengyi12
Copy link

What problem does this feature solve?

If I use

this.$router.push({
      name: 'pageB',
      query: {
        money: 100, // number
      }
 })

jump to pageB

now

// pageB
export default {
  mounted(){
     console.log(typeof this.$route.query.money)
     // case1 If the page enters as push, then the output is [number]
     // case2 If this page B is refreshed, then the output is [string]
  }
}

Since the requery type cannot be retrieved from the current URL when re-entering the page,
So should the type of the unified parameter always be string to avoid some unnecessary type problems?

using Google Translate Thanks

What does the proposed API look like?

Uniform parameter type is String

@posva
Copy link
Member

posva commented Nov 8, 2018

IMO yes, they should always be casted to strings to make things consistent

@tesla3327
Copy link

tesla3327 commented Nov 22, 2018

Related to #2131

@posva
Copy link
Member

posva commented Nov 22, 2018

Let's close this in favour of #2131 . We should allow numbers and string for convenience but cast things to strings for consistency

@posva posva closed this as completed Nov 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants