如何解决Bootstrap Navbar问题Erorr:404

时间:2019-12-29 17:06:48

标签: twitter-bootstrap navbar

我有一个瓶颈服务器,本地app.py,并且在网络浏览器中打开http://localhost:8080/
服务器从我小的index.tpl文件开始。我在导航栏菜单内链接另一个名为history.tpl的页面时遇到问题
当我打开localhost:8080 index.tpl时,正常启动,但是单击“历史记录”链接会导致

  

错误:404找不到很抱歉,请求的URL'http://localhost:8080/history.tpl'导致错误:找不到:   '/history.tpl'

这是index.tpl

enter code here
<!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="description" content="PY_Bottle_template">
<meta name="author" content="datamate">
<title>FC Bayern</title>
<link rel="stylesheet" type="text/css" href="/static/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/static/custom.css">
<script type="text/javascript" src="/static/assets/js/jquery.js"></script>
<script type="text/javascript" src="/static/assets/js/custom.js"></script>
<script type="text/javascript" src="/static/assets/js/bootstrap.min.js"></script> 
</head>
<body>

<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">
<div class="container">
<a class="navbar-brand" href="#">FC Bayern</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" 
aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item" id="history"> <a class="nav-link" href="history.tpl">History</a>
</li>
</ul>
</div>
</div>
</nav> 

custom.js是

$("history").on("click",history);
function history()
{
window.location.assign("history.tpl");
}

1 个答案:

答案 0 :(得分:0)

尝试将标签href属性保留为空白。因此,删除href中的“ history.tpl”。如果我是你,我也将其更改为按钮标签。

<li class="nav-item"> <button id="history" class="nav-link">History</button>