Skip to main content

<svelte:document>

<svelte:document onevent={handler} />
<svelte:document bind:prop={value} />

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

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

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

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

<svelte:document onvisibilitychange={handleVisibilityChange} use:someAction />

你还可以绑定到以下属性:

¥You can also bind to the following properties:

  • activeElement

  • fullscreenElement

  • pointerLockElement

  • visibilityState

全部都是只读的。

¥All are readonly.

上一页 下一页