html - 引导轮播按钮仅适用于第一项(来自 jinja 循环),其余项目不起作用
问题描述
面对一些奇怪的错误。对于引导轮播,prev/next 按钮仅适用于 item 中的第一项,不适用于以后的第二项。但是,在我单击轮播后,我可以使用左右箭头键导航轮播,但按钮仍然不起作用。以前有人遇到过这样的问题吗?
PS:了解必须在此处粘贴可行的代码,但我不知道该怎么做
items_modals.html
<div class="modal fade" id="Modal-MoreInfo-{{ item.name }}"
tabindex="-1"
aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="ModalLabel">
{{ item.long_name }}
</h5>
<button type="button" class="close"
data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
{% for x in img %}
{% if x.item_id == item.id %}
<div class="carousel-item {% if '_1.jpg' in x.img_path %} active {% endif%}">
<img class="d-block w-100" src="../../{{ x.img_path }}" alt="">
</div>
{% endif %}
{% endfor %}
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" 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="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<p style="text-align:left">Dimensions: {{item.dimension }}</p>
<br>
{{ item.description }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary"
data-dismiss="modal">Close
</button>
</div>
</div>
</div>
产品.html
{% extends 'layout.html' %}
{% block title%}
Products
{% endblock %}
{% block content %}
<table class="table table-hover">
<thead>
<tr>
<!-- Your Columns HERE -->
<!--th scope="col">ID</th-->
<th scope="col" style="text-align: left;">Name</th>
<th scope="col">Price</th>
<th scope="col">Options</th>
</tr>
</thead>
<tbody>
<!-- Your rows inside the table HERE: -->
{% for item in items %}
{% include 'includes/items_modals.html' %}
<tr>
<!-- td>{{ item.id }}</td -->
<td style="text-align: left;">{{ item.long_name }}</td>
<td>${{ item.price }}</td>
<td>
<button class="btn btn-primary" data-toggle="modal" data-target="#Modal-MoreInfo-{{ item.name }}">More Info</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
路线.py
@app.route('/product')
def product():
items = Item.query.all()
img = Item_img.query.all()
return render_template('product.html',items = items, img= img)
解决方案
推荐阅读
- ios - (React Native) npm run ios 出错,构建命令失败:PhaseScriptExecution
- google-sheets - 我在使用谷歌表格的查询功能时遇到问题
- python - 有没有比三重嵌套 for 循环更好的方法来连接三个列表中的元素?
- react-native - 领域 - 第二次插入抛出错误:错误:“xxx”必须是“字符串”类型,得到“空”(空)
- css - CSS 动画目前仅适用于 Firefox,不适用于 Chrome 或 Safari
- c# - 从响应中删除属性名称
- r - Shiny Dashboard 中的问题,带有警告 massege“强制引入的 NA”
- javascript - .click() 方法无法识别
- python - 如何为传递给另一个类的 kwarg 添加类型提示,而无需复制我的提示和/或文档?
- azure-devops - 如何更改工作项历史记录中的 CreatedBy?