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

Allow props for every attribute in to on router-link (like name, params, query) #2818

Open
Bigdragon13th opened this issue Jun 20, 2019 · 2 comments
Labels
feature request group[router-link redesign] Issues regarding a redesign in current router-link implementation to make it make it more customizab needs RFC This feature request needs to go through the RFC process to gather more information

Comments

@Bigdragon13th
Copy link

Bigdragon13th commented Jun 20, 2019

What problem does this feature solve?

In my projects, I always link to the routes using route name (and also set it as a standard of my team). e.g.

<router-link :to="{ name: 'productList' }">Product List</router-link>
<router-link :to="{ name: 'productItem', params: { id: 1 }}">Product Detail</router-link>

I found this pattern is unnecessary too long and not convenient to use compare to a much shorter syntax of using route link

<router-link to="/products-list">Product List</router-link>
<router-link to="/products/1">Product Detail</router-link>

Anyway, I still want to use named route everywhere (for the sake of maintainability & scalability) and feel like link to named route can be improved.

What does the proposed API look like?

I want the :to to be able to link to named route as-is (so when we created a route object somewhere else, we can bind it easily). But maybe you can make another prop for named route, such as:

<router-link toName="productList">Product List</router-link>
<router-link toName="productItem" :params="{ id: 1 }">Product Detail</router-link>

Or (I don't know if it possible) custom modifiers?:

<router-link to.name="productList">Product List</router-link>
<router-link to.name="productItem" :params="{ id: 1 }">Product Detail</router-link>
@posva posva changed the title [Feature Request] Make link to a named route more easier Allow props for every attribute in to on router-link (like name, params, query) Jun 24, 2019
@posva
Copy link
Member

posva commented Jun 24, 2019

A modifier is indeed not possible. I think using the attribute name directly would make more sense

@posva posva added the group[router-link redesign] Issues regarding a redesign in current router-link implementation to make it make it more customizab label Aug 1, 2019
@oppianmatt
Copy link

You've got a small syntax error with your example (missing =), also see my now closed duplicate proposal format:

I would propose something like

<router-link to="productItem" :params="{ id: 1 }">Product Detail 1</router-link>

That keeps the to field backwards compatible but let you provide params and other parameters

@posva posva added the needs RFC This feature request needs to go through the RFC process to gather more information label Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request group[router-link redesign] Issues regarding a redesign in current router-link implementation to make it make it more customizab needs RFC This feature request needs to go through the RFC process to gather more information
Projects
None yet
Development

No branches or pull requests

3 participants