hx-history
将当前文档中任何元素或 htmx 加载到当前文档中的任何 html 片段上的 hx-history
属性设置为 false
,以防止在 htmx 拍摄页面状态快照时将敏感数据保存到 localStorage 缓存中。
¥Set the hx-history
attribute to false
on any element in the current document, or any html fragment loaded into the current document by htmx, to prevent sensitive data being saved to the localStorage cache when htmx takes a snapshot of the page state.
历史导航将按预期工作,但在恢复时,将从服务器而不是历史缓存请求 URL。
¥History navigation will work as expected, but on restoration the URL will be requested from the server instead of the history cache.
这是一个例子:
¥Here is an example:
<html>
<body>
<div hx-history="false">
...
</div>
</body>
</html>
¥Notes
hx-history="false"
可以存在于文档中的任何位置,以禁止当前页面状态进入历史缓存(即,甚至在为历史快照 hx-history-elt 指定的元素之外)。
¥hx-history="false"
can be present anywhere in the document to embargo the current page state from the history cache (i.e. even outside the element specified for the history snapshot hx-history-elt).