其他分享
首页 > 其他分享> > react-router(v5)路由更新但页面没刷新

react-router(v5)路由更新但页面没刷新

作者:互联网

参考其他大佬的解决方法,把默认的 / 路由放在最下面就可以了

router.js

<BrowserRouter>
        <Switch>
            <Route path="/login" component={Login} />
            <Route path="/pinfo" component={Pinfo}/>
            <Route path="/" component={App} />

        </Switch>
    </BrowserRouter>

pinfo.js

 <Switch>
	<Route path="/pinfo/pfrom" component={Pfrom}/>
	<Route path="/pinfo/projectfrom" component={ProjectFrom}/>
	<Redirect to="/pinfo/pfrom"/>
</Switch>

这样就可以在 pinfo 里的展示区切换展示他的子组件了
参考链接:react路由更新 页面不更新

标签:更新,js,react,pinfo,v5,router,路由
来源: https://blog.csdn.net/weixin_46235143/article/details/121729480