[英]Link in React Router not redirecting to page
The NavLink is not redirecting to the specified page: "api/pages/abc": NavLink 未重定向到指定页面:“api/pages/abc”:
import { BrowserRouter as Link } from 'react-router-dom';
class MyPage extends React.Component{
render(){
return(
<Dropdown.Menu>
<Link to="api/pages/abc">
<Dropdown.Item >
Edit
</Dropdown.Item>
</Link>
</Dropdown.Menu>
);
}
}
export default MyPage;
in another file:在另一个文件中:
import { BrowserRouter as Link, Router, Route, Switch } from 'react-router-dom';
<Router>
<Switch>
<Route path="api/pages/abc" component={MyPage} />
</Switch>
</Router>
What might be the problem, why it is not redirecting to the specified page: "api/pages/abc"?可能是什么问题,为什么它没有重定向到指定的页面:“api/pages/abc”?
You are import Link wrong, Instead of this你是导入链接错误,而不是这个
import { BrowserRouter as Link } from 'react-router-dom';
use this用这个
import { Link } from "react-router-dom";
docs: https://reactrouter.com/web/guides/quick-start文档: https://reactrouter.com/web/guides/quick-start
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.