所以我有2条路线,分别是/first
和/second
。当我去http://localhost:3000/
时,我看不到任何东西,因为我根本没有任何东西(/
)。所以我想知道是否有可能使http://localhost:3000/
直接重定向到http://localhost:3000/review
或有没有其他方法使它成为可能?
<Router history={history}>
<div>
<Route
path="/first"
render={() => <myComponent />}
exact
/>
<Route
path="/second"
render={() => <secondComponent />}
/>
</div>
/>
必须在Route
之后添加重定向,并将所有内容包装在Switch
中。
<Router history={history}>
<Switch>
<Route
path="/review"
render={() => <RateReviewStep cancelRateReview={this.cancelRateReview} />}
exact
/>
<Route
path="/confirm"
render={() => <RateConfirmationStep model={model} fields={fields} />}
/>
<Redirect from="/" to="review" />
</Switch>
</Router>