2024-10-01 13:43:14 发布
网友
在HTML中,我可以直接链接到页面上的特定位置,假设有一个具有给定id的元素:
<a href="http://www.example.com/stuff.html#exactlocation">Go there</a>
在Flask中,我试图给render_template添加锚定,但是我得到了jinja2.exceptions.TemplateNotFound: stuff.html#exactlocation。在
render_template
jinja2.exceptions.TemplateNotFound: stuff.html#exactlocation
如何链接到模板中的特定位置?在
多亏了迪恩的评论,我设法用下面的代码实现了这一点。在
将_anchor关键字传递给url_for以向生成的URL追加锚定。在
_anchor
url_for
导航菜单:
<a href="{{ url_for('.stuff', _anchor='exactlocation') }}">Go to specific id on suff page</a>
烧瓶路径:
stuff.html:
stuff.html
... <section id="exactlocation"> ...
多亏了迪恩的评论,我设法用下面的代码实现了这一点。在
将
_anchor
关键字传递给url_for
以向生成的URL追加锚定。在导航菜单:
烧瓶路径:
^{pr2}$stuff.html
:相关问题 更多 >
编程相关推荐