flask 分页

<nav class="blog-pagination" aria-label="Pagination">
{% if paginate.has_prev %}
<a class="btn btn-outline-primary rounded-pill" href="{{ url_for('index.index', page=paginate.prev_num) }}">上一页</a>
{% else %}
<a class="btn btn-outline-primary rounded-pill" href="#">上一页</a>
{% endif %}

<!-- 显示所有存在的页码 -->
{% for num in range(1, paginate.pages + 1) %}
<a class="btn btn-outline-primary rounded-pill {% if num == paginate.page %}active{% endif %}" href="#">{{ num }}</a>
{% endfor %}

{% if paginate.has_next %}
<a class="btn btn-outline-secondary rounded-pill" href="{{ url_for('index.index', page=paginate.next_num) }}">下一页</a>
{% else %}
<a class="btn btn-outline-secondary rounded-pill disabled">下一页</a>
{% endif %}
</nav>

 

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注