警告:失败的道具类型:道具 `to` 在 `Link` 中被标记为必需,但其值为 `undefined`

lak*_*aJS 7 reactjs react-router

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>
    );
  };
};
Run Code Online (Sandbox Code Playgroud)

无法真正看到我的错误,但我知道其中存在错误。我去了链接标签,因为那是 react-router-dom 中错误指向的地方

Nor*_*tz7 7

在Link中,您必须添加“to”,如果您不是真的将路由器用于任何不应该使用Link的事情,但是如果出于某种原因您需要它,那么就这样做

<Link to="/#"><Button bsStyle="primary">About</Button></Link>

同样,如果你真的使用这个到路由器关于你应该使用


ma_*_*_15 4

        <Link>
            <Button bsStyle="primary">About</Button>
        </Link>
Run Code Online (Sandbox Code Playgroud)

您需要在链接中添加to

        <Link to="/about">
            <Button bsStyle="primary">About</Button>
        </Link>
Run Code Online (Sandbox Code Playgroud)