【问题标题】:How can I prevent react-router Link to direct to the middle of a new view?如何防止 react-router 链接指向新视图的中间?
【发布时间】:2017-11-29 08:58:51
【问题描述】:

当我使用简单的链接时:

import {Link} from 'react-router-dom'

<Link
  className="btn btn-primary btn-lg"
  to={'/path'}>
  Learn More
</Link>

新视图在页面中间而不是顶部打开。我该如何改变呢?谢谢。

【问题讨论】:

  • 你使用的是哪个版本的 react-router?
  • 如何检查?
  • 在您的package.json 文件中检查react-router 的版本。
  • "react-router": "^4.1.1", "react-router-dom": "^4.1.1",
  • 好的,在这种情况下,请查看react-router scroll to top on every transition。您可能会在那里找到答案。

标签: reactjs react-router


【解决方案1】:

查看 React Router 文档中的 Scroll Restoration

【讨论】:

    猜你喜欢
    • 2019-02-26
    • 2016-11-22
    • 1970-01-01
    • 1970-01-01
    • 2016-01-20
    • 1970-01-01
    • 2015-01-06
    • 1970-01-01
    • 2017-05-26
    相关资源
    最近更新 更多