0

****(主要问题链接应该可以工作,但它应该封装在路由器内部。如果封装比明显,它会像嵌套路由器。我不想要。我只想在单击链接时呈现注册组件以下)****

返回 (

            <h1>Login Page</h1>

         Its the login form, no issue with login form
            <form action="">

                <button }>Login</button>

            </form>

           <

           **(The main issue is this should work, but it should be encapsulate inside the router. If encapsulated than obviously , it would like nested router. which i dont want. i just want to render register component only when i click the link below)**


          <Link to="" component={Register}> Create Account </Link>


        </div>
     );
4

1 回答 1

0

您能否尝试使用 Link 来声明路径,然后在开关内使用 Route 来提供功能。

 <h1>Login Page</h1>

   Its the login form, no issue with login form
            <form action="">
                <button>Login</button>
            </form>


   <Link to="path/here" component={Register}> Create Account </Link>

   <Switch>
   <Route path="path/here">
   < Register />
   </Route>
   </Switch>

当然,您必须导入 Route 和 Switch

于 2020-03-27T12:34:00.677 回答