首页 > 解决方案 > 反应中文本的超链接

问题描述

如何在我尝试过的文本上建立链接请帮助我做错了什么

当我单击立即加入时,注册是组件文本唯一的路径更改,例如注册/

<BrowserRouter>
     <Link to="/Signup"> Join now</Link>
</BrowserRouter>

错误

index.js:2178 Warning: validateDOMNesting(...): <a> cannot appear as a descendant of <a>.
    in a (created by Link)
    in Link (at Login.js:205)
    in Router (created by BrowserRouter)
    in BrowserRouter (at Login.js:203)
    in a (at Login.js:123)
    in MyLink (created by WithStyles(MyLink))
    in WithStyles(MyLink) (at Login.js:200)
    in p (created by Typography)
    in Typography (created by WithStyles(Typography))
    in WithStyles(Typography) (at Login.js:197)
    in div (created by Paper)
    in Paper (created by WithStyles(Paper))
    in WithStyles(Paper) (created by Card)
    in Card (created by WithStyles(Card))
    in WithStyles(Card) (at Login.js:166)
    in div (at Login.js:164)
    in Login (created by WithStyles(Login))
    in WithStyles(Login) (at App.js:35)
    in div (at App.js:33)
    in App (created by WithStyles(App))
    in WithStyles(App) (at index.js:9)

标签: reactjs

解决方案


import React from 'react';
import ReactDOM from 'react-dom';
import {BrowserRouter as Router, Route, NavLink} from 'react-router-dom';

ReactDOM.render(
<Router>
  <div>
    <ul>
      {/*You can add more links here*/}
      <li><NavLink to='/Signup'>Join Now</NavLink></li>
    </ul>

    <hr/>

    <Route path='/SignUp' component={ComponentName} />
  </div>
)

推荐阅读