【发布时间】:2020-04-29 02:10:43
【问题描述】:
我有一个带有一些按钮的btn-group,每个按钮都会指向不同的页面。 btn-group 将在每个页面上可见。
这是btn-group的html,
<div class="btn-group-lg text-center" role="group" aria-label="Basic example">
<a class="btn btn-outline-primary" href="" role="button">Home</a>
<a class="btn btn-outline-primary" href="view_schedule/" role="button">Schedule</a>
<a class="btn btn-outline-primary" href="view_syllabus/" role="button">Syllabus</a>
<a class="btn btn-outline-primary" href="view_records/" role="button">Records</a>
<a class="btn btn-outline-primary" href="view_achievements/" role="button">Achievements</a>
<a class="btn btn-outline-primary" href="view_gallery/" role="button">Gallery</a>
<a class="btn btn-outline-primary" href="view_contact/" role="button">Contact</a>
<a class="btn btn-outline-primary" href="about/" role="button">About Us</a>
</div>
但每当我按下按钮时,它都会修改地址栏中的 URL。 示例:- 从http://127.0.0.1:8000/shotokankaratebd/ 开始,如果我按下计划按钮,它会将 URL 更改为 http://127.0.0.1:8000/shotokankaratebd/view_schedule。
之后,如果我再次按计划按钮,它会将其更改为 http://127.0.0.1:8000/shotokankaratebd/view_schedule/view_schedule,这是一个无效的 URL,我会收到错误消息。
我该如何编写,以便每当按下按钮时,只影响http://127.0.0.1:8000/shotokankaratebd/之后的部分?
已编辑以包含新的 href:
<a class="btn btn-outline-primary" href="../shotokankaratebd/" role="button">Home</a>
<a class="btn btn-outline-primary" href="../shotokankaratebd/view_schedule/" role="button">Schedule</a>
<a class="btn btn-outline-primary" href="../shotokankaratebd/view_syllabus/" role="button">Syllabus</a>
<a class="btn btn-outline-primary" href="../shotokankaratebd/view_records/" role="button">Records</a>
<a class="btn btn-outline-primary" href="../shotokankaratebd/view_achievements/" role="button">Achievements</a>
<a class="btn btn-outline-primary" href="../shotokankaratebd/view_gallery/" role="button">Gallery</a>
<a class="btn btn-outline-primary" href="../shotokankaratebd/view_contact/" role="button">Contact</a>
<a class="btn btn-outline-primary" href="../shotokankaratebd/about/" role="button">About Us</a>
【问题讨论】:
-
你试过
../吗? -
我刚试过。但是,如果我按下 Home 按钮以外的任何东西,同样的问题仍然存在。我已编辑问题以包含新的 href。
标签: javascript html css django twitter-bootstrap