在"react-router-dom"中更新呈现的组件可以通过以下几种方式实现:
import { Route } from 'react-router-dom';
import Component1 from './Component1';
import Component2 from './Component2';
// ...
<Route path="/path1" component={Component1} />
<Route path="/path2" component={Component2} />
import { Route } from 'react-router-dom';
import Component1 from './Component1';
import Component2 from './Component2';
// ...
<Route path="/path1" render={() => <Component1 />} />
<Route path="/path2" render={() => <Component2 />} />
import { Route } from 'react-router-dom';
import Component1 from './Component1';
import Component2 from './Component2';
// ...
<Route path="/path1">
{() => <Component1 />}
</Route>
<Route path="/path2">
{() => <Component2 />}
</Route>
以上是在"react-router-dom"中更新呈现的组件的几种常见方式。根据具体的需求和场景,选择适合的方式来更新组件。
领取专属 10元无门槛券
手把手带您无忧上云