1.2.8
版本发布时间: 2024-01-24 07:14:59
vanjs-org/van最新发布版本:1.5.2(2024-08-20 05:09:27)
In this release, we changed the implementation of event handlers in VanJS. Instead of registering event handlers via on...
property, we changed to use addEventListener
and removeEventListener
to register and unregister event handlers.
As a result of the change, you can set custom event handlers via tag functions:
const {button, div, p} = van.tags
const dom = div(button({oncustom: () => van.add(dom, p("Event triggered!"))}, "Button"))
van.add(document.body, dom)
dom.querySelector("button").dispatchEvent(new Event("custom"))