htmx 1.x → htmx 2.x 迁移指南

本指南的目的是提供从 htmx 1.x 到 htmx 2.x 的迁移说明。我们非常重视向后兼容性,因此在大多数情况下,这种迁移几乎不需要任何工作。

¥The purpose of this guide is to provide instructions for migrations from htmx 1.x to htmx 2.x. We place a very high value on backwards compatibility, so in most cases this migrations should require very little, if any, work.

要使用新方法进行交换,你只需使用

¥To do a swap using new method, you need to simply use

let content = "<div>Hello world</div>"; // this is HTML that will be swapped into target
let target = api.getTarget(child);
let swapSpec = api.getSwapSpecification(child);
api.swap(target, content, swapSpec);

swap 方法文档可在 JS API 参考 上获得

¥swap method documentation is available on JS API Reference

htmx 2.0 不再支持 IE,但 htmx 1.x 继续支持 IE,并将在可预见的未来得到支持。

¥IE is no longer supported in htmx 2.0, but htmx 1.x continues to support IE and will be supported for the foreseeable future.

升级音乐

¥Upgrade Music

这是官方的 htmx 1.x -> 2.x 升级音乐:

¥This is the official htmx 1.x -> 2.x upgrade music: