]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
docs: improve guards (#729)
authorzhufengzhufeng <894918097@qq.com>
Thu, 4 Feb 2021 12:18:18 +0000 (20:18 +0800)
committerGitHub <noreply@github.com>
Thu, 4 Feb 2021 12:18:18 +0000 (13:18 +0100)
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com>
docs/guide/advanced/navigation-guards.md

index 124f3d117a2712f49321b9c4266265170bf9dfa5..0a94508024f2d53a180ff358cc08ca91ef849e15 100644 (file)
@@ -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'
 })
 ```