hx-put
hx-put
属性将导致元素向指定的 URL 发出 PUT
,并使用交换策略将 HTML 交换到 DOM 中:
¥The hx-put
attribute will cause an element to issue a PUT
to the specified URL and swap
the HTML into the DOM using a swap strategy:
<button hx-put="/account" hx-target="body">
Put Money In Your Account
</button>
此示例将导致 button
向 /account
发出 PUT
并将返回的 HTML 交换到 body
的 innerHTML
中。
¥This example will cause the button
to issue a PUT
to /account
and swap the returned HTML into
the innerHTML
of the body
.
¥Notes
hx-put
不是继承的
¥hx-put
is not inherited
你可以使用 hx-target 属性控制交换的目标
¥You can control the target of the swap using the hx-target attribute
你可以使用 hx-swap 属性控制交换策略
¥You can control the swap strategy by using the hx-swap attribute
你可以使用 hx-trigger 属性控制触发请求的事件
¥You can control what event triggers the request with the hx-trigger attribute
你可以通过多种方式控制随请求提交的数据,记录在此处:参数
¥You can control the data submitted with the request in various ways, documented here: Parameters