【发布时间】:2015-07-27 21:49:12
【问题描述】:
我不知道这是我遇到的反应路由器问题还是嵌套路由问题,甚至是数据问题。我正在将一个同构的单页应用程序与 react Flux 和 node/express 一起破解,我无法理解为什么有时在我的 /reports 和 /reports/:id 路由上,如果我循环它会吐出没有数据/或空数组通过很多路线(比如在 /reports 和每个不同的 /reports/:id 之间来回移动,最终其中一个会吐出未定义的(当时任何随机的),当我返回仪表板然后返回我的数据时( /reports) 都是空的。如果我点击刷新,它会说等待 localhost... 永远(就像 1 分钟 + 永远在网络上),然后我必须重新启动服务器。
我的路线是这样的:
<Route>
<Route name ="dash" path="/dashboard" handler={App}>
<Route name ="dashboard" path="/dashboard" handler={Dashboard}/>
<Route name ="assignReport" path="/user" handler={AssignReport}/>
<Route name ="assignReported" path="/user/:id" handler={AssignReported}/>
<Route name ="employees" path="/employees" handler={Employees}/>
<Route name ="reports" path="/reports" handler={Report}/>
<Route name ="singlereports" path="/reports/:id" handler={ReportView}/>
<Route name ="addsubreport" path="/reports/:id/addsubreport" handler={AddSubreport}/>
<Route name ="editreports" path="/reports/:id/edit" handler={EditReport}/>
<Route name ="MyEmployees" path="/MEmployees" handler={MyEmployees}/>
<Route name ="AllEmployees" path="/AEmployees" handler={AllEmployees}/>
<Route name ="Profile" path="/profile" handler={Profile}/>
<Route name ="reportstocomplete" path="/reportsc" handler={ReportsToComplete}/>
<Route name ="addReport" path="/addReport" handler={AddReports}/>
<Route name ="readme" path="/readme" handler={Readme}/>
<Route name ="statistics" path="/statistics" handler={Stats}/>
<Route name ="signup" path="/signup" handler={Signup} />
<Route name ="login" path="/" handler={Login} />
<Route name ="newreport" path="/newreport" handler={NewReport}/>
<Route name ="templatereport" path="/templatereport" handler={TemplateReport}/>
</Route>
</Route>
编辑:我意识到这可能不是路由问题,但很可能是 ajax 问题。我可能加载异步数据太慢了。我通过搜索用户名而不是 id 来获取每个文档,这可能是这种情况。有什么想法吗?
编辑:它甚至可能不是 ajax 问题,问题不会发生在 IE 上,我可以一遍又一遍地刷新和获取数据,但是在 IE 上发布数据时遇到问题。在 chrome 上它会说等待 localhost... 一段时间。
编辑:我可以在 firefox 上向路由发送垃圾邮件,并且它始终可以正常工作。当我在浏览器中输入 localhost:3000 时它不能正常工作,因此输入 IP 允许它工作(127.0.0.1);对 chrome 做同样的事情,在一堆垃圾邮件(10 - 20 个路由垃圾邮件(单击后退和前进/alt 右和 alt 左)之后,我仍然无法定义并卡在 localhost 上)
【问题讨论】:
标签: javascript ajax node.js reactjs react-router