Skip to main content

<svelte:body>

<svelte:body onevent={handler} />

<svelte:window> 类似,此元素允许你向 document.body 上的事件添加监听器,例如 mouseentermouseleave,这些事件不会在 window 上触发。它还允许你在 <body> 元素上使用 actions

¥Similarly to <svelte:window>, this element allows you to add listeners to events on document.body, such as mouseenter and mouseleave, which don’t fire on window. It also lets you use actions on the <body> element.

<svelte:window><svelte:document> 一样,此元素只能出现在组件的顶层,并且绝不能位于块或元素内。

¥As with <svelte:window> and <svelte:document>, this element may only appear the top level of your component and must never be inside a block or element.

<svelte:body onmouseenter={handleMouseenter} onmouseleave={handleMouseleave} use:someAction />
上一页 下一页