hx-ext
hx-ext
属性为元素及其所有子元素启用 htmx extension。
¥The hx-ext
attribute enables an htmx extension for an element and all its children.
值可以是单个扩展名,也可以是要应用的扩展名的逗号分隔列表。
¥The value can be a single extension name or a comma-separated list of extensions to apply.
如果你希望插件应用于整个 DOM,则可以将 hx-ext
标签放在父元素上,并将其放在 body
标签上以使其应用于所有 htmx 请求。
¥The hx-ext
tag may be placed on parent elements if you want a plugin to apply to an entire swath of the DOM,
and on the body
tag for it to apply to all htmx requests.
¥Notes
hx-ext
既可以继承也可以与父元素合并,因此你可以在 DOM 层次结构中的任何元素上指定扩展,它将应用于所有子元素。
¥hx-ext
is both inherited and merged with parent elements, so you can specify extensions on any element in the DOM
hierarchy and it will apply to all child elements.
你可以忽略使用 hx-ext="ignore:extensionName"
的父节点定义的扩展
¥You can ignore an extension that is defined by a parent node using hx-ext="ignore:extensionName"
<div hx-ext="example">
"Example" extension is used in this part of the tree...
<div hx-ext="ignore:example">
... but it will not be used in this part.
</div>
</div>
<body hx-ext="preload,morph">
"preload" and "morph" extensions are used in this part of the tree...
</body>