import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { Jumbotron, Grid, Row, Col, Image, Button } from 'react-bootstrap';
import './Home.css';
export default class Home extends Component{
render() {
return (
<Grid>
<Jumbotron>
<h2>Welcome to Judic-O Couture.io</h2>
<p>Understang the basics of react, react-bootstrap & react-router-dom.</p>
</Jumbotron>
<Link>
<Button bsStyle="primary">About</Button>
</Link>
</Grid>
);
};
};
无法真正看到我的错误,但我知道其中存在错误。我已经转到链接标签,因为那是错误在react-router-dom中指向的地方
最佳答案
在 Link 中你必须添加“to”,如果你没有真正使用路由器做任何事情,你不应该使用 Link,但如果出于某种原因你需要它,那么就这样做
<Link to="/#"><Button bsStyle="primary">About</Button></Link>
再说一次,如果你真的在路由器上使用它,你应该使用 <Link to="/your-path"
或任何您想使用的路线。
更新:
我还是不明白为什么你有<button>
在你的链接里面。如果出于某种原因你需要一个功能,你可以在链接中添加 onClik,如果是出于设计目的,你可以添加 className='my-class'
关于reactjs - 警告 : Failed prop type: The prop `to` is marked as required in `Link` , 但其值为 `undefined`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54477122/