#2688·vue-router

Support array syntax in `beforeEnter`

Author: posvaCreated Mar 28, 2019Updated Jul 31, 2024
Labelsfeature requestfixed on 4.x

What problem does this feature solve?

This will allow splitting guard logic in smaller functions and making it easy to chain them. It's similar to express middlewares

What does the proposed API look like?

javascript
{ path: '/some', beforeEnter: [authGuard, adminGuard] }

current solution to this: https://www.npmjs.com/package/vue-router-multiguard

Edit: Supporting arrays for in-component guards seems unnecessary as a component guard is specific to a component, they are not reused. On top of that, the typing of this would probably break so I removed them from the proposal.