Skip to content

There's no way to global handle for onAbort in vue router (Check onError). Implement global onAbort router lifecycle hook. #3286

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
afwn90cj93201nixr2e1re opened this issue Aug 8, 2020 · 3 comments

Comments

@afwn90cj93201nixr2e1re
Copy link

No description provided.

@afwn90cj93201nixr2e1re
Copy link
Author

afwn90cj93201nixr2e1re commented Aug 8, 2020

Version

3.3.4

Reproduction link

https://1.1

Steps to reproduce

1

What is expected?

Add new global VUE ROUTER onAbort HANDLE

What is actually happening?

nothing


#2956 (comment)

As i said, just check the code, you missed onError callback calling here: https://github.com/vuejs/vue-router/blob/dev/src/history/base.js#L107 , but checking for false here: https://github.com/vuejs/vue-router/blob/dev/src/history/base.js#L153

simple code:
beforeRouteEnter(to, from, next){
if(1){next(new Error('This gonna call onError global route Hook');return;}
if(1){next(false);return;}//but that's not, this call only onAbort local route link.
}

i know, thats expected coz that's onError which mean calback should be called only on Error, but how we should operate/hook on false next on global level, which also stop routing?

I think you should add ||error===false
or create new global hook for router which called onCancel.

You really need repo for this?

@afwn90cj93201nixr2e1re
Copy link
Author

Right now i should everytime patch vue router just for getting this functionality, coz i need to stop progress bars/loading bars on any page Aborts, but i cant, coz it's not implemented yet.

@posva

@posva
Copy link
Member

posva commented Aug 8, 2020

Use afterEach and onError. Also see https://router.vuejs.org/guide/advanced/navigation-failures.html. Don't open issues without following the template

@posva posva closed this as completed Aug 8, 2020
@afwn90cj93201nixr2e1re afwn90cj93201nixr2e1re changed the title There's no way to global handle for onAbort in vue router (Check onError) There's no way to global handle for onAbort in vue router (Check onError). Implement global onAbort router lifecycle hook. Aug 8, 2020
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