Skip to content

About http://router.vuejs.org #1334

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

Closed
bigZ-again opened this issue Apr 14, 2017 · 4 comments
Closed

About http://router.vuejs.org #1334

bigZ-again opened this issue Apr 14, 2017 · 4 comments

Comments

@bigZ-again
Copy link

bigZ-again commented Apr 14, 2017

What problem does this feature solve?

I am learning router, I want to programmatic navigation from a path(components) to other path.
Because call router.push() in components isn't valid. I must emit a event to parent.
I just add @jump="myjump" at router-view tag, everything is OK.
But I can't find any description about it in http://router.vuejs.org.

What does the proposed API look like?

The vue's document is simple, clear, effective for me. I hope it would be better, so I suggest to add a little description about how to emit a event from components to parent, and how to capture components' event.
Just a little.
Thanks.

@LinusBorg
Copy link
Member

LinusBorg commented Apr 14, 2017

Because call router.push() in components isn't valid.

Of course that is valid.

I just add @jump="myjump" at router-view tag, everything is OK. But I can't find any description about it in http://router.vuejs.org.

That's probably because we already explain that all components in vue-router are normal Vue components, so everything works the same.

Personally, I understand that very broad and well explained documentation is very helpul for beginners, but at the same time, documentation should be limited to the topic of the lib it is describing, or else the same things are repeated in multiple places and will create more work or possibilities for future mismatches when things change.

I hope it would be better, so I suggest to add a little description about how to emit a event from components to parent, and how to capture components' event.

For the above reason, I don't think that we should explain in detail how Vue components work the same in the vue-router docs. But we could add a small mentioning here:

Behaviour

Any non-name props and anyv-on event bindings will be passed along to the rendered component, however most of the time the per-route data is contained in the route's params.

@bigZ-again
Copy link
Author

@LinusBorg Thank for your very detail explanation, and I agree with your opinion.
I should make some mistakes before. "router" is global, router.push() can be called in anything. so $emit is complicated.
Maybe someone like this:
let vm = new Vue({ router: new VueRouter({routes}) })
In this case, $emit is necessary.

@LinusBorg
Copy link
Member

Did you miss the fact that you can access the router from any component through this.$router

@posva
Copy link
Member

posva commented Apr 14, 2017

This should be more clear with #1304
We should just deploy the docs again

Basically, you can do $router.push in templates 🙂

@posva posva closed this as completed Apr 14, 2017
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