How to use react-router to jump to specific location in the page

喜夏-厌秋 提交于 2019-12-11 02:32:40

问题


I am trying to build a parallax website with react and react-router

In most react-router examples I found, target dom node is replaced with Handler corresponding to the route.

var routes = (
    <Route handler={App} path="/">
        <DefaultRoute handler={Home} />
        <Route name="about" handler={About} />
        <Route name="users" handler={Users} />
    </Route>
);

Router.run(routes, function (Handler) {
    React.render(<Handler/>, document.body);
});

How can I render all the route handlers into single page and jump to specific location in a page with react-router ?


回答1:


I think what you want to use is the <Link to="#LOCATION" />. It says in the documentation about the to attribute of the Link tag: The name of the route to link to, or a full URL.. Try that and see if that works.



来源:https://stackoverflow.com/questions/28590040/how-to-use-react-router-to-jump-to-specific-location-in-the-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!