From 04fee1400cbfcd3bb1ea669d1da02e1bf85eca8c Mon Sep 17 00:00:00 2001 From: zhufengzhufeng <894918097@qq.com> Date: Thu, 4 Feb 2021 20:18:18 +0800 Subject: [PATCH] docs: improve guards (#729) Co-authored-by: Eduardo San Martin Morote --- docs/guide/advanced/navigation-guards.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/guide/advanced/navigation-guards.md b/docs/guide/advanced/navigation-guards.md index 124f3d11..0a945080 100644 --- a/docs/guide/advanced/navigation-guards.md +++ b/docs/guide/advanced/navigation-guards.md @@ -37,7 +37,8 @@ All of the the things above **work the same way with `async` functions** and Pro ```js router.beforeEach(async (to, from) => { // canUserAccess() returns `true` or `false` - return await canUserAccess(to) + const canAccess = await canUserAccess(to) + if (!canAccess) return '/login' }) ``` -- 2.47.3