我有兴趣了解执行以下功能的正确方法:
<li {% if request.path == '/' or '/<int> %}class="active"{% endif %}><a href="{{ url_for('index') }}"><i class="fa fa-home" aria-hidden="true"></i> Home</a></li>
上述方法确实有效,如果访问“/ article / 3”或“/ anything /”等网址,也会触发“有效”类。
我尝试了以下内容:
<li {% if request.path == '/<int> %}class="active"{% endif %}><a href="{{ url_for('index') }}"><i class="fa fa-home" aria-hidden="true"></i> Home</a></li>
整数表示页码,默认设置为1。