]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
docs: note about toRef
authorEduardo San Martin Morote <posva13@gmail.com>
Sat, 21 Nov 2020 09:16:08 +0000 (10:16 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Sat, 21 Nov 2020 09:16:08 +0000 (10:16 +0100)
docs/guide/advanced/extending-router-link.md

index 7c00b6a3b2de42a234b9da3ac59f8d1c15a857cc..46973c5c19abf2a838e686c6cd3f786dad60d924 100644 (file)
@@ -9,7 +9,12 @@ Let's extend RouterLink to handle external links as well and adding a custom `in
   <a v-if="isExternalLink" v-bind="$attrs" :href="to" target="_blank">
     <slot />
   </a>
-  <router-link v-else v-bind="$props" custom v-slot="{ isActive, href, navigate }">
+  <router-link
+    v-else
+    v-bind="$props"
+    custom
+    v-slot="{ isActive, href, navigate }"
+  >
     <a
       v-bind="$attrs"
       :href="href"
@@ -57,6 +62,8 @@ export default {
   },
 
   setup(props) {
+    // toRef allows us to extract one prop and keep it reactive
+    // https://v3.vuejs.org/api/refs-api.html#toref
     const { navigate, href route, isActive, isExactActive } = useLink(toRef(props, 'to'))