【发布时间】:2015-07-27 18:37:53
【问题描述】:
当我尝试重定向到我的任务详细信息页面并且我想刷新它时,我收到错误 404 File not found from my index.html 因为我的样式表路径和 scripts.js 路径从 localhost:8080/styles 更改.css 到 localhost:8080/tasks/style.css 我不知道为什么会这样?
我的html代码:
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/cssfamily=Open+Sans:400,300,600' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- build:css css/application.css -->
<link rel="stylesheet" href="styles.css">//BREAKS HERE
<!-- endbuild -->
</head>
<body>
<main class="site-content" id="main">
<p>Main content</p>
</main>
<!-- build:js js/application.js -->
<script src="scripts.js"></script>//AND BREAKS HERE
<!-- endbuild -->
</body>
我正在使用 react-router,但我对 react 还很陌生,所以我不知道问题是否在这里。
路线:
<Route handler={App}>
<Redirect from="/" to="login" />
<Route name="login" path="login" handler={Login} />
<Route name="dashboard" path="dashboard" handler={Dashboard} />
<Route name="task" path="/tasks/:id" handler={Task} />
</Route>
当我在仪表板刷新时工作正常,但当我转到任务/:id 并刷新页面时,我收到此错误:
22821:14 GET http://localhost:8080/tasks/styles.css
22821:27 GET http://localhost:8080/tasks/scripts.js
Failed to load a resource: the server responded with status of 404
【问题讨论】:
标签: url get request reactjs react-router