在url_for方法中,您可以传入_anchor参数以在页面加载时加载定位标记。
我将如何使用render_template做同样的事情?
我可以
render_template('profile/index.html')
没有任何问题,但是当我在html的末尾添加锚标记并尝试执行此操作时
render_template('profile/index.html#h1")
我收到找不到模板的错误
jinja2.exceptions.TemplateNotFound
TemplateNotFound: profile/index.html#h1
本质上,这就是我最终要做的事情,我传入了一个值以及render_template
return render_template('profile/index.html', set_tab=1)
在javascript的客户端上,我执行了以下操作来设置标签
<script>
var obj_load={% if set_tab==1%}1{%else%}0{%endif%};
tab_load=(obj_load?"#h1":"#");
$(document).ready(function () {
if(location.hash || obj_load) {
$('a[href=' + (location.hash || tab_load) + ']').tab('show');
}
});
</script>
fyi,即时通讯使用bootstrap 3的标签窗格
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句