【发布时间】:2021-07-06 11:37:10
【问题描述】:
我正在使用 fullpage.js 制作我的作品集,我想在每次滚动到下一个元素时添加一条路线。例如:当我打开页面时,我在该部分中获得了<Home /> 元素我想在滚动到第二个元素<About /> 放置路由器/#about 时放置路由器/#home,依此类推,因为我这样做?
const Fullpagescroll = () =>{
return (
<>
<Header />
<ReactFullpage
scrollingSpeed = {1150}
navigation
render={() => {
return (
<>
<div className='section'>
<Home />
</div>
<div className='section'>
<About />
</div>
<div className='section'>
<Project />
</div>
<div className='section'>
<Contact />
</div>
</>
);
}}
/>
</>
);
}
例子
<Router>
<div className='section' >
<Route path='/#home'>
<Home />
</Route>
</div>
<div className='section'>
<Route path='/#about'>
<About />
</Route>
</div>
<div className='section'>
<Route path='/#project'>
<Project />
</Route>
</div>
<div className='section'>
<Route path='/#contact'>
<Contact />
</Route>
</div>
</Router>
【问题讨论】:
-
根据文档,
recordHistory默认为true,但无论如何,请尝试在 scrollingSpeed 属性下方添加recordHistory={true}。 -
这不起作用,因为我想在
<Home />中创建该部分的路径,添加路径 localhost:333/#home,在这种情况下滚动到下一个部分<About />我想把路径改成localhost:333/#about
标签: javascript reactjs fullpage.js