我犯的错误是假设
Modal
存在于
editor
. 我有这个:
const {Button, Modal} = editor;
将导入更正为以下内容,修复了此问题:
const {Button, Modal} = wp.components;
在后端,当您注册组件时,您将希望
wp-components
wp_register_script(
'recipe-block',
ZRDN_PLUGIN_DIRECTORY_URL . $relativeScriptPath, // File.
array( 'wp-components','wp-blocks', 'wp-i18n', 'wp-compose', 'wp-editor', 'wp-data','wp-element', 'underscore' ), // Dependencies.
filemtime( ZRDN_PLUGIN_DIRECTORY . $relativeScriptPath ) // filemtime â Gets file modification time.
);