单页应用在使用router进行跳转之后,比如从index跳转到其他页面,在跳转之后的页面进行F5刷新,就会渲染出错:
react找不到这个节点了
我的router是这样写的, 主要使用了react-router,页面的跳转用的是<Link to=""></Link>
import React from "react";
import {Router, Route, IndexRedirect} from "react-router";
import {TreeRoutes, PlainRoutes} from "./routes";
import StudentList from "../containers/Homepage/StudentList";
const loadModule = (callback) => (componentModule) => {
callback(null, componentModule.default);
};
export default ({history}) => {
return <Router history={history}>
<Route path={TreeRoutes.index}>
<IndexRedirect to={PlainRoutes.video_monitor.index}/>
<Route path={TreeRoutes.video_monitor.index}
getComponent={(location, callback) => {
const renderRoute = loadModule(callback);
System.import('containers/App')
.then((component) => {
renderRoute(component)
})
}}>
...
</Route>
</Route>
</Router>
有什么问题么,谢谢!
3 回答1.9k 阅读✓ 已解决
1 回答1.6k 阅读✓ 已解决
4 回答1.6k 阅读✓ 已解决
2 回答2.5k 阅读✓ 已解决
1 回答2.5k 阅读✓ 已解决
2 回答1.3k 阅读✓ 已解决
2 回答1.6k 阅读✓ 已解决
Talk is cheap, show the code.