我有如下的路由器和导航页面。
<Router>
<Switch>
<Route path="/reports" component={Reports} />
<Route path="/line-monitoring" component={LineMonitoring} />
<Route path="/device-management" component={DeviceManagement} />
<Route path="/" exact component={Dashboard} />
</Switch>
<Router>
<NavLink onClick="" to="/" exact>Dashboard</NavLink>
<NavLink onClick="" to="/device-management">Device Management</NavLink>
<NavLink onClick="" to="/line-monitoring">Line Monitoring</NavLink>
<NavLink onClick="" to="/reports">Reports</NavLink>问题是,每当我单击标题导航时,整个页面都在刷新。我怎么才能避免它。
发布于 2018-08-09 16:07:51
也许你可以使用shouldComponentUpdate方法?如果你用withRouter方法包装你的组件,它将在你每次改变location属性时重新呈现
https://stackoverflow.com/questions/51761299
复制相似问题