【问题标题】:Flask url_for DIV ID烧瓶 url_for DIV ID
【发布时间】:2021-06-29 20:28:53
【问题描述】:

我使用 Flask url_for 作为我的 Flask 应用程序的一部分进行重定向。

例如

next_page = url_for('help.index')

这将重定向到:<a href="http://example.com/help">

是否可以将 div id 传递给url_for 以重定向到:

<a href="http://example.com/help#shipping">?

【问题讨论】:

  • 我相信 url_for 接受 _anchor 参数。否则,您可以使用良好的旧字符串连接

标签: python flask url-for


【解决方案1】:

而不是url for,我这样做是这样的

`next_page = "/help#shipping"`

这将做同样的事情,但如果你想使用 url_for 来做,那么

`next_page = f"{url_for("help.index")}#shipping"`

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-01
    • 1970-01-01
    • 2016-01-12
    • 2012-05-06
    • 1970-01-01
    • 2018-07-13
    • 2023-03-09
    • 1970-01-01
    相关资源
    最近更新 更多