vuejs / router

🚦 The official router for Vue.js
https://router.vuejs.org/
MIT License
3.88k stars 1.18k forks source link

beforeEach return false cause blank page when directly accessing that url #2287

Closed a1mersnow closed 3 months ago

a1mersnow commented 3 months ago

Reproduction

https://stackblitz.com/edit/vue3-vite-router-starter-69rngy?file=package.json

Steps to reproduce the bug

When I click the About link, it successfully forbids me from entering /about. However, when I click the nav button, it just leaves a blank page without rendering anything.

Expected behavior

As for the document, it should redirect to the from path.

Actual behavior

Rendering nothing

Additional information

I wonder if this is in design or if there are some tech limits in implementing this feature. If so, how should I resolve the problem? And is using return false a bad idea? Maybe I should return from.path

posva commented 3 months ago

This is the expected behavior

a1mersnow commented 3 months ago

@posva So, what if people directly access a route which is tackled by 'return false'? Isn't it a wrong case?

a1mersnow commented 3 months ago

I think we should improve the documentation however.