vuejs / router

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

The value of the top property in the scrollBehavior documentation should be corrected. #2029

Closed yoshi-pi closed 10 months ago

yoshi-pi commented 10 months ago

Reproduction

https://router.vuejs.org/guide/advanced/scroll-behavior.html

Steps to reproduce the bug

  1. Scroll down to the following code:
    const router = createRouter({
    scrollBehavior(to, from, savedPosition) {
    // always scroll 10px above the element #main
    return {
      // could also be
      // el: document.getElementById('main'),
      el: '#main',
      top: -10,
    }
    },
    })
  2. Check the value of the top property

Expected behavior

The top property should be 10, considering #2027.

Actual behavior

The top property is -10.

Additional information

No response

posva commented 10 months ago

Don’t open duplicates please. The behavior won’t be changed as it would break everyone’s code and there is no reason to