gpt4 book ai didi

twitter-bootstrap - Bootstrap 轮播不适用于 flask 路由

转载 作者:行者123 更新时间:2023-12-03 16:48:14 25 4
gpt4 key购买 nike

我在 index.html 中有这个 HTML 代码:

{% block header %}
<header>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<!-- Slide One - Set the background image for this slide in the line below -->
<div class="carousel-item active" style="background-image: url('http://placekitten.com/1900/1080')">
<div class="carousel-caption d-none d-md-block">
<h3>First Slide</h3>
<p>This is a description for the first slide.</p>
</div>
</div>
<!-- Slide Two - Set the background image for this slide in the line below -->
<div class="carousel-item" style="background-image: url('http://placekitten.com/1900/1080')">
<div class="carousel-caption d-none d-md-block">
<h3>Second Slide</h3>
<p>This is a description for the second slide.</p>
</div>
</div>
<!-- Slide Three - Set the background image for this slide in the line below -->
<div class="carousel-item" style="background-image: url('http://placekitten.com/1900/1080')">
<div class="carousel-caption d-none d-md-block">
<h3>Third Slide</h3>
<p>This is a description for the third slide.</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</header>
{% endblock %}

这是我的 flask 路由器:
@app.route('/')
@app.route('/index')
def index():
return render_template('index.html')

问题是,当我单击轮播上的下一步按钮时,它不起作用,显示的 URL 是:
http://127.0.0.1:5000/index#carouselExampleIndicators

我知道问题很明显,但我想不出解决方案。我试图保持 index.html 独立.. 或试图将 carousel id 发送回路由器,然后从那里开始.. 但我所有的尝试都是无用的。我使用 Bootstrap 4.1.3 和 flask 1.0.2。

最佳答案

看起来 index.html 页面缺少 Bootstrap 的链接。您可以从 https://getbootstrap.com/docs/4.3/getting-started/download/ 获取 bootstrap.css 和 bootstrap.min.js并将 css 和 js 文件夹保存在 flask 模板文件夹(放置 index.html 的位置)中。

添加 <link rel="stylesheet" type="text/css" href="css/bootstrap.css">{% block header %} 之后和 <script src="js/bootstrap.min.js"></script>之前 {% endblock %}应该使轮播中的图像滑动正常工作

例如:

{% block header %}
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<header>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
.... YOUR HTML CODE FOR CAROUSEL GOES HERE ....
</div>
</header>
<script src="js/bootstrap.min.js"></script>
{% endblock %}

关于twitter-bootstrap - Bootstrap 轮播不适用于 flask 路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53874232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com