在 DOM 加载完成后执行回调函数。

安装

安装模块

npm install @wordpress/dom-ready --save

此包假设您的代码将在 ES2015+ 环境中运行。如果您使用的环境有限或完全不支持此类语言特性和 API,您应该在代码中包含@wordpress/babel-preset-default 随附的 polyfill。

API

default

指定在 DOM 完全加载后执行的函数。

用法

import domReady from '@wordpress/dom-ready';

domReady( function () {
    //do something after DOM loads.
} );

参数

  • callback VoidFunction: 在 DOM 就绪后执行的函数。

浏览器支持

请参阅 https://make.wordpress.org/core/handbook/best-practices/browser-support/

为此包做出贡献

这是 Gutenberg 项目的一部分独立包。该项目组织为 monorepo。它由多个自包含的软件包组成,每个包都有特定的用途。此 monorepo 中的包发布到 npm,并被 WordPress 以及其他软件项目使用。

要了解有关为此包或整个 Gutenberg 做出贡献的更多信息,请阅读项目的主要 贡献者指南。