reactjs - 反应中文本的超链接
问题描述
如何在我尝试过的文本上建立链接请帮助我做错了什么
当我单击立即加入时,注册是组件文本唯一的路径更改,例如注册/
<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)
解决方案
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>
)
推荐阅读
- java - How to select items from dropdown list by selenium
- git - VSTS 存储库拉取请求
- python - 避免使用多个相同类型的窗口
- node.js - 在 Express 中哪里放置错误处理程序中间件?
- windows-machine-learning - 例外:“参数不正确。” 尝试使用卷积运行 ONNX 模型时
- vector - 三.JS | 如何找出两个向量之间的 XYZ 旋转?
- r - 找到数字 signif(2) 四舍五入到?
- c# - 使用不同 DataContext 中的两个 Combobox 进行 MultiBinding
- app-store-connect - 多个 TestFlight 构建停留在“处理”上,包括已处理的
- httpresponse - 什么时候 HTTP 响应代码实际上是 200 OK?