]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
docs: improve
authorEduardo San Martin Morote <posva13@gmail.com>
Sun, 11 Oct 2020 11:04:02 +0000 (13:04 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Sun, 11 Oct 2020 11:04:02 +0000 (13:04 +0200)
docs/guide/advanced/scroll-behavior.md

index 7063f2653df762cb3b1d02f6527bc0291a69c7c9..c9012618049d855f1fa23a905ba86490708ff08b 100644 (file)
@@ -25,7 +25,7 @@ const router = createRouter({
   scrollBehavior(to, from, savedPosition) {
     // always scroll to top
     return { top: 0 }
-  }
+  },
 })
 ```
 
@@ -33,13 +33,15 @@ You can also pass a CSS selector or a DOM element via `el`. In that scenario, `t
 
 ```js
 const router = createRouter({
-  scrollBehavior (to, from, savedPosition) {
+  scrollBehavior(to, from, savedPosition) {
     // always scroll 10px above the element #main
-    // el: '#main'
-    // could also be
-    // el: document.getElementById('main'),
-    return { el: '#main',  top: -10 }
-  }
+    return {
+      // could also be
+      // el: document.getElementById('main'),
+      el: '#main',
+      top: -10,
+    }
+  },
 })
 ```
 
@@ -55,7 +57,7 @@ const router = createRouter({
     } else {
       return { top: 0 }
     }
-  }
+  },
 })
 ```
 
@@ -66,10 +68,10 @@ const router = createRouter({
   scrollBehavior(to, from, savedPosition) {
     if (to.hash) {
       return {
-        el: to.hash
+        el: to.hash,
       }
     }
-  }
+  },
 })
 ```
 
@@ -100,7 +102,7 @@ const router = createRouter({
         resolve({ left: 0, top: 0 })
       }, 500)
     })
-  }
+  },
 })
 ```