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

Expose a way to get route string from a router object. #2690

Closed
trandaison opened this issue Apr 1, 2019 · 1 comment
Closed

Expose a way to get route string from a router object. #2690

trandaison opened this issue Apr 1, 2019 · 1 comment

Comments

@trandaison
Copy link

What problem does this feature solve?

I think it would be nice if there is a helper function that parse an object to an URL based on matched route from routers list.

Currently, we have to use <router-link> and bind that object to :to, but what if I want to bind a <a :href="">?

<a :href="`/video/${video.id}`?t=${video.t}`">

This is ok. However, sometimes, the route path changes (for example: /videos instead of /video), in that case we have to find all the <a> and replace with the new path, I don't think it's a good idea.

But if we use the route name instead of the path, it will work despite of changing route path.

What does the proposed API look like?

this.$router.parseURL({ name: 'Video', params: { id: 'funny-video' }, query: { t: 200 } })

// /video/funny-video?t=200
@posva
Copy link
Member

posva commented Apr 1, 2019

Use the resolve method

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

No branches or pull requests

2 participants