{% for num in page_num %} {% if num is page %} <li class="active"><a href="/blog/index?page={{num}}">{{num}}</a></li> {% else %} <li><a href="/blog/index?page={{num}}">{{num}}</a></li> {% endif%} {% endfor %}
但需要传入page变量:
{ 'article_list': page_article_list, 'page_num': range(1, page_num + 1), 'curr_page': page, 'next_page': next_page, 'previous': previous_page, 'top10_article_list': top10_article_list, 'page': page })
点赞~
{% for num in page_num %}
{% if num == curr_page %}
<li class="active"><a href="/blog/index?page={{num}}">{{ num }}<span class="sr-only">(current)</span></a></li>
{% else %}
<li><a href="/blog/index?page={{num}}">{{ num }}</a></li>
{% endif %}
{% endfor %}