React Router不渲染路由,但是设置了路径变量

时间:2019-08-13 14:32:58

标签: reactjs react-router

我试图使用我的React路由器根据浏览器中的路径呈现一个组件。正确设置了路径,并且{this.props.location}对象返回了正确的路径。但我的路由器似乎无法正常工作。

路由器文件

import React from 'react';
import { Router, Route, Switch } from 'react-router-dom';
import Infopage from './setSubscriptionPage';
import TrialRequestForm from './trialRequestForm';
import { createBrowserHistory } from 'history';

const history = createBrowserHistory();

class SubscriptionActions extends React.Component {
    render() {
        console.log(this.props.location);
        return (
            <React.Fragment>
                make a decission
                <Router history={history}>
                    <div>
                        <Route exact path='/trial' Component={TrialRequestForm} />
                        <Route exact path='/teams' Component={Infopage} />
                    </div>
                </Router>
            </React.Fragment>
        );
    }
}

export default SubscriptionActions;

浏览器: enter image description here

任何提示将不胜感激。干杯!

1 个答案:

答案 0 :(得分:3)

您的问题在这里,

<Route exact path='/trial' Component={TrialRequestForm} />

您用大写Component写的C应该是componentc

<Route exact path='/trial' component={TrialRequestForm} />