HTML/CSS 有用过 htmx 的老哥吗?和 Turbolinks 类似的前端方案

shiweifu · October 22, 2021 · Last by ericguo replied at October 22, 2021 · 490 hits

网站

https://htmx.org/

介绍

htmx allows you to access AJAX, CSS Transitions, WebSockets and Server Sent Events directly in HTML, using attributes, so you can build modern user interfaces with the simplicity and power of hypertext

例子

<!-- Load from unpkg -->
<script src="https://unpkg.com/[email protected]"></script>
<!-- have a button POST a click via AJAX -->
<button hx-post="/clicked" hx-swap="outerHTML">
  Click Me
</button>

The hx-post and hx-swap attributes tell htmx:

"When a user clicks on this button, issue an AJAX request to /clicked, and replace the entire button with the response"

似乎和 Turbolinks 有些类似。

学习参考: https://blog.logrocket.com/htmx-the-newest-old-way-to-make-web-apps/

这不就是 10 年前的 pajax 吗

turbo 其实真的不错,Rails 7 即将首发,也经过一年打磨了,turbo_frame_tag 甚至可以说是指哪打哪,而且还可以一个动作更新页面的多处地方。htmx 我随便看了一眼,兼容 IE 11 其实在 2021 年 11 月,微软都放弃了的情况下,只能理解为固步自封。现在哪个框架发新版本,还支持 IE 11,我第一个放弃它。

You need to Sign in before reply, if you don't have an account, please Sign up first.