Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs react路由器v4单页滚动_Reactjs_React Router V4 - Fatal编程技术网

Reactjs react路由器v4单页滚动

Reactjs react路由器v4单页滚动,reactjs,react-router-v4,Reactjs,React Router V4,是否可以使用react router v4构建滚动到锚定链接页面?就像这里的例子。除了带有组件的SPA之外,RRv4文档中没有一个演示如何构建它 这是我用HTML写的 <nav> <a href="#section1"> Section 1 </a> <a href="#section2"> Section 2 </a> <a href="#section3"> Section 3 </a> <nav

是否可以使用react router v4构建滚动到锚定链接页面?就像这里的例子。除了带有组件的SPA之外,RRv4文档中没有一个演示如何构建它

这是我用HTML写的

<nav>
 <a href="#section1"> Section 1 </a>
 <a href="#section2"> Section 2 </a>
 <a href="#section3"> Section 3 </a>
<nav>


<section id="#section1"> Section 1 </section>
<section id="#section2"> Section 2 </section>
<section id="#section3"> Section 3 </section>

第一节
第二节
第三节
如何使用React路由器更正写一个

const AppRouter = () => (
    <BrowserRouter>
        <div>
            <Header />
            <Switch>
                <Route path="/" exact={true} />
                <Route path="/second" />
                <Route path="/third" />
            </Switch>
        </div>
    </BrowserRouter>
);

const Header = () => (
  <header>
      <NavLink 
            to="#section1" 
            activeClassName="is-active" 
            exact={true}> Section 1</NavLink>
      <NavLink 
            to="#section2" 
            activeClassName="is-active">Section 2</NavLink>
      <NavLink 
            to="#section3" 
            activeClassName="is-active">Section 3</NavLink>
  </header>
); 
const AppRouter=()=>(
);
常量头=()=>(
第一节
第二节
第三节
); 

提前谢谢

只需使用锚元素,你能详细说明吗?您能解释一下如何或在哪里使用锚元素吗?