我使用的反應路由器具有的路由路徑taskSupport/:advertiserId
使用參數,但是當我嘗試去聯繫,http://localhost:8080/taskSupport/advertiserId
,我收到了一堆的404(未找到)我所有的CSS錯誤文件和我的client.min.js文件。 任何人都知道發生了什麼事?對不起,我是一個反應noob ... 任何幫助將不勝感激!陣營路由器W /網址參數
<Route path="/">
<IndexRoute component={Layout}></IndexRoute>
<Route path="about" component={About}></Route>
<Route path="referral" component={Referral}></Route>
<Route path="taskSupport(/:advertiserId)" name="taskSupport" component={TaskSupport}></Route>
<Route path="faq" component={Faq}></Route>
<Route path="faq-plain" component={FaqPlain}></Route>
</Route>
我的HTML文件:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- <meta name="viewport" content="width=device-width, initial-scale=1"> -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>BitMaker</title>
<link rel="icon" type="image/png" href="img/bitmaker.png" />
<link rel="stylesheet" type="text/css" href="css/stylesheet.css">
<link rel="stylesheet" type="text/css" href="css/faq.css">
<link rel="stylesheet" type="text/css" href="css/error404.css">
<link rel="stylesheet" type="text/css" href="css/about.css">
<link rel="stylesheet" type="text/css" href="css/taskSupport.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css" />
<link href="http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Prompt:300,400,500,600,700" rel="stylesheet">
<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div id="app">
appHtml
</div>
<script src="client.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
</body>
你可以添加在CSS和JS文件拉動HTML?您可以使用相對鏈接,嘗試從「/taskSupport/:advertiserID/filename.ext」而不是從域的根目錄獲取它們。請改用taskSupport的此路徑路徑:「taskSupport /:advertiserId」,不要使用圓括號。 –
括號只是使advertiserId參數可選。我將添加我的html文件 – Esther
噢好吧所以是的,你正在使用相對鏈接爲您的資源,它試圖從你在哪裏的位置抓住他們。要將它們從根目錄中取出,請將參考鏈接以'/'開頭,如'/css/stylesheet.css'和'/client.min.js'。 –