无法使Gutenberg InspectorControls工作

时间:2019-07-16 作者:egolive

我试图创建一个块,我想使用InspectorControl,但我无法让它工作。我知道它的反对意见/改为wp。组件。*(https://developer.wordpress.org/block-editor/developers/backward-compatibility/deprecations/)

但如果是那样使用它,它仍然不起作用。我尝试了以下方法:

InspectorControls = wp.editor;
InspectorControls = wp.editor.InspectorControls;
InspectorControls = wp.blocks;
InspectorControls = wp.blocks.InspectorControls;
InspectorControls = wp.components;
InspectorControls = wp.components.InspectorControls;
这是我的代码:

let el = wp.element.createElement,
    registerBlockType = wp.blocks.registerBlockType,
    ServerSideRender = wp.components.ServerSideRender,
    TextControl = wp.components.TextControl,
    TextareaControl = wp.components.TextareaControl,
    InspectorControls = wp.editor;

registerBlockType( \'mir-shortcodes-plugin/msc-rotating-icon-circle\', {
    title: \'Rotating icon circle\',
    category: \'msc-shortcodes\',

    attributes: {
        \'icon\': {
            type: \'string\',
            default: "arrows-alt"
        },
        \'icon_style\': {
            type: \'string\',
            default: "fas"
        }
    },

    edit: (props) => {

        if(props.isSelected){
            // do something...
            //console.debug(props.attributes);
        };

        return [
            /**
             * Server side render
             */
            el("div", {
                    className: "mb-editor-container",
                    style: {textAlign: "center"}
                },
                el( ServerSideRender, {
                    block: \'mir-shortcodes-plugin/msc-rotating-icon-circle\',
                    attributes: props.attributes
                } )
            ),

            /**
             * Inspector
             */
            el( InspectorControls,
                {}, [
                    el( "hr", {
                        style: {marginTop:20}
                    }),

                    el( TextControl, {
                        label: \'Icon\',
                        value: props.attributes.icon,
                        onChange: ( value ) => {
                            props.setAttributes( { icon: value } );
                        }
                    } ),

                    el( TextControl, {
                        label: \'Icon color\',
                        value: props.attributes.icon_color,
                        onChange: ( value ) => {
                            props.setAttributes( { icon_color: value } );
                        }
                    } ),
                ]
            )
        ]
    },

    save: () => {
        /** this is resolved server side */
        return null
    }
} );
错误日志:

[Error] Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it\'s defined in, or you might have mixed up default and named imports.

Check the render method of `edit`.
    in edit (created by Edit)
    in Edit (created by WithToolbarControls(Edit))
    in WithToolbarControls(Edit) (created by WithInspectorControl(WithToolbarControls(Edit)))
    in WithInspectorControl(WithToolbarControls(Edit)) (created by WithInspectorControl(WithInspectorControl(WithToolbarControls(Edit))))
    in WithInspectorControl(WithInspectorControl(WithToolbarControls(Edit)))
    in Unknown (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(Component) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithMultipleValidation(WithInspectorControl(WithInspectorControl(WithToolbarControls(Edit)))) (created by WithFilters(Edit))
    in WithFilters(Edit) (created by BlockEdit)
    in BlockEdit (created by HoverArea)
    in BlockCrashBoundary (created by HoverArea)
    in div (created by IgnoreNestedEvents)
    in IgnoreNestedEvents (created by ForwardRef(IgnoreNestedEvents))
    in ForwardRef(IgnoreNestedEvents) (created by HoverArea)
    in div (created by HoverArea)
    in div (created by IgnoreNestedEvents)
    in IgnoreNestedEvents (created by ForwardRef(IgnoreNestedEvents))
    in ForwardRef(IgnoreNestedEvents) (created by HoverArea)
    in HoverArea (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(HoverArea) (created by BlockListBlock)
    in BlockListBlock
    in Unknown (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in (BlockListBlock) (created by WithFilters(BlockListBlock))
    in WithFilters(BlockListBlock) (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(WithFilters(BlockListBlock)) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(WithFilters(BlockListBlock))) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithViewportMatch(WithSelect(WithDispatch(WithFilters(BlockListBlock)))) (created by Pure(WithViewportMatch(WithSelect(WithDispatch(WithFilters(BlockListBlock))))))
    in Pure(WithViewportMatch(WithSelect(WithDispatch(WithFilters(BlockListBlock))))) (created by BlockList)
    in div (created by BlockList)
    in BlockList (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(BlockList) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(BlockList))
    in Unknown (created by VisualEditor)
    in div (created by CopyHandler)
    in CopyHandler (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(CopyHandler) (created by VisualEditor)
    in div (created by ObserveTyping)
    in ObserveTyping (created by WithSafeTimeout(ObserveTyping))
    in WithSafeTimeout(ObserveTyping) (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(WithSafeTimeout(ObserveTyping)) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(WithSafeTimeout(ObserveTyping))) (created by VisualEditor)
    in div (created by WritingFlow)
    in div (created by WritingFlow)
    in WritingFlow (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(WritingFlow) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(WritingFlow)) (created by VisualEditor)
    in div (created by BlockSelectionClearer)
    in BlockSelectionClearer (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(BlockSelectionClearer) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(BlockSelectionClearer)) (created by VisualEditor)
    in VisualEditor (created by Layout)
    in div (created by Layout)
    in div (created by FocusReturnProvider)
    in FocusReturnProvider (created by Layout)
    in Layout (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithViewportMatch(Layout) (created by NavigateRegions(WithViewportMatch(Layout)))
    in div (created by NavigateRegions(WithViewportMatch(Layout)))
    in NavigateRegions(WithViewportMatch(Layout)) (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(NavigateRegions(WithViewportMatch(Layout))) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(NavigateRegions(WithViewportMatch(Layout)))) (created by Editor)
    in ErrorBoundary (created by Editor)
    in div (created by DropZoneProvider)
    in DropZoneProvider (created by BlockEditorProvider)
    in SlotFillProvider (created by BlockEditorProvider)
    in BlockEditorProvider (created by Context.Consumer)
    in WithRegistry(BlockEditorProvider) (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(WithRegistry(BlockEditorProvider)) (created by EditorProvider)
    in EditorProvider (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(EditorProvider) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(EditorProvider)) (created by Editor)
    in StrictMode (created by Editor)
    in Editor (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(Editor)
    warningWithoutStack (react.js:276)
    warning (react.js:1791)
    createElementWithValidation (react.js:3023)
    edit (index.js:74)
    renderWithHooks (react-dom.js:13027)
    mountIndeterminateComponent (react-dom.js:15109)
    performUnitOfWork (react-dom.js:19401)
    workLoop (react-dom.js:19441)
    renderRoot (react-dom.js:19524)
    performWorkOnRoot (react-dom.js:20431)
    performWork (react-dom.js:20343)
    performSyncWork (react-dom.js:20317)
    interactiveUpdates$1 (react-dom.js:20584)
    dispatchInteractiveEvent (react-dom.js:4985)
    dispatchInteractiveEvent
[Error] Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it\'s defined in, or you might have mixed up default and named imports.

Check the render method of `edit`.
    in edit (created by Edit)
    in Edit (created by WithToolbarControls(Edit))
    in WithToolbarControls(Edit) (created by WithInspectorControl(WithToolbarControls(Edit)))
    in WithInspectorControl(WithToolbarControls(Edit)) (created by WithInspectorControl(WithInspectorControl(WithToolbarControls(Edit))))
    in WithInspectorControl(WithInspectorControl(WithToolbarControls(Edit)))
    in Unknown (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(Component) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithMultipleValidation(WithInspectorControl(WithInspectorControl(WithToolbarControls(Edit)))) (created by WithFilters(Edit))
    in WithFilters(Edit) (created by BlockEdit)
    in BlockEdit (created by HoverArea)
    in BlockCrashBoundary (created by HoverArea)
    in div (created by IgnoreNestedEvents)
    in IgnoreNestedEvents (created by ForwardRef(IgnoreNestedEvents))
    in ForwardRef(IgnoreNestedEvents) (created by HoverArea)
    in div (created by HoverArea)
    in div (created by IgnoreNestedEvents)
    in IgnoreNestedEvents (created by ForwardRef(IgnoreNestedEvents))
    in ForwardRef(IgnoreNestedEvents) (created by HoverArea)
    in HoverArea (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(HoverArea) (created by BlockListBlock)
    in BlockListBlock
    in Unknown (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in (BlockListBlock) (created by WithFilters(BlockListBlock))
    in WithFilters(BlockListBlock) (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(WithFilters(BlockListBlock)) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(WithFilters(BlockListBlock))) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithViewportMatch(WithSelect(WithDispatch(WithFilters(BlockListBlock)))) (created by Pure(WithViewportMatch(WithSelect(WithDispatch(WithFilters(BlockListBlock))))))
    in Pure(WithViewportMatch(WithSelect(WithDispatch(WithFilters(BlockListBlock))))) (created by BlockList)
    in div (created by BlockList)
    in BlockList (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(BlockList) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(BlockList))
    in Unknown (created by VisualEditor)
    in div (created by CopyHandler)
    in CopyHandler (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(CopyHandler) (created by VisualEditor)
    in div (created by ObserveTyping)
    in ObserveTyping (created by WithSafeTimeout(ObserveTyping))
    in WithSafeTimeout(ObserveTyping) (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(WithSafeTimeout(ObserveTyping)) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(WithSafeTimeout(ObserveTyping))) (created by VisualEditor)
    in div (created by WritingFlow)
    in div (created by WritingFlow)
    in WritingFlow (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(WritingFlow) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(WritingFlow)) (created by VisualEditor)
    in div (created by BlockSelectionClearer)
    in BlockSelectionClearer (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(BlockSelectionClearer) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(BlockSelectionClearer)) (created by VisualEditor)
    in VisualEditor (created by Layout)
    in div (created by Layout)
    in div (created by FocusReturnProvider)
    in FocusReturnProvider (created by Layout)
    in Layout (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithViewportMatch(Layout) (created by NavigateRegions(WithViewportMatch(Layout)))
    in div (created by NavigateRegions(WithViewportMatch(Layout)))
    in NavigateRegions(WithViewportMatch(Layout)) (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(NavigateRegions(WithViewportMatch(Layout))) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(NavigateRegions(WithViewportMatch(Layout)))) (created by Editor)
    in ErrorBoundary (created by Editor)
    in div (created by DropZoneProvider)
    in DropZoneProvider (created by BlockEditorProvider)
    in SlotFillProvider (created by BlockEditorProvider)
    in BlockEditorProvider (created by Context.Consumer)
    in WithRegistry(BlockEditorProvider) (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(WithRegistry(BlockEditorProvider)) (created by EditorProvider)
    in EditorProvider (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(EditorProvider) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(EditorProvider)) (created by Editor)
    in StrictMode (created by Editor)
    in Editor (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(Editor)
    warningWithoutStack (react.js:276)
    warning (react.js:1791)
    createElementWithValidation (react.js:3023)
    edit (index.js:74)
    renderWithHooks (react-dom.js:13027)
    mountIndeterminateComponent (react-dom.js:15109)
    performUnitOfWork (react-dom.js:19401)
    workLoop (react-dom.js:19441)
    callCallback (react-dom.js:143)
    dispatchEvent
    invokeGuardedCallbackDev (react-dom.js:193)
    invokeGuardedCallback (react-dom.js:250)
    replayUnitOfWork (react-dom.js:18667)
    renderRoot (react-dom.js:19557)
    performWorkOnRoot (react-dom.js:20431)
    performWork (react-dom.js:20343)
    performSyncWork (react-dom.js:20317)
    interactiveUpdates$1 (react-dom.js:20584)
    dispatchInteractiveEvent (react-dom.js:4985)
    dispatchInteractiveEvent
[Error] Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it\'s defined in, or you might have mixed up default and named imports.

Check the render method of `edit`.
    invariant (react-dom.js:56)
    createFiberFromTypeAndProps (react-dom.js:10314)
    createFiberFromElement (react-dom.js:10335)
    createChild (react-dom.js:12114)
    reconcileChildrenArray (react-dom.js:12365)
    reconcileChildren (react-dom.js:14491)
    mountIndeterminateComponent (react-dom.js:15153)
    performUnitOfWork (react-dom.js:19401)
    workLoop (react-dom.js:19441)
    callCallback (react-dom.js:143)
    dispatchEvent
    invokeGuardedCallbackDev (react-dom.js:193)
    invokeGuardedCallback (react-dom.js:250)
    replayUnitOfWork (react-dom.js:18667)
    renderRoot (react-dom.js:19557)
    performWorkOnRoot (react-dom.js:20431)
    performWork (react-dom.js:20343)
    performSyncWork (react-dom.js:20317)
    interactiveUpdates$1 (react-dom.js:20584)
    dispatchInteractiveEvent (react-dom.js:4985)
    dispatchInteractiveEvent
[Error] The above error occurred in the <edit> component:
    in edit (created by Edit)
    in Edit (created by WithToolbarControls(Edit))
    in WithToolbarControls(Edit) (created by WithInspectorControl(WithToolbarControls(Edit)))
    in WithInspectorControl(WithToolbarControls(Edit)) (created by WithInspectorControl(WithInspectorControl(WithToolbarControls(Edit))))
    in WithInspectorControl(WithInspectorControl(WithToolbarControls(Edit)))
    in Unknown (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(Component) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithMultipleValidation(WithInspectorControl(WithInspectorControl(WithToolbarControls(Edit)))) (created by WithFilters(Edit))
    in WithFilters(Edit) (created by BlockEdit)
    in BlockEdit (created by HoverArea)
    in BlockCrashBoundary (created by HoverArea)
    in div (created by IgnoreNestedEvents)
    in IgnoreNestedEvents (created by ForwardRef(IgnoreNestedEvents))
    in ForwardRef(IgnoreNestedEvents) (created by HoverArea)
    in div (created by HoverArea)
    in div (created by IgnoreNestedEvents)
    in IgnoreNestedEvents (created by ForwardRef(IgnoreNestedEvents))
    in ForwardRef(IgnoreNestedEvents) (created by HoverArea)
    in HoverArea (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(HoverArea) (created by BlockListBlock)
    in BlockListBlock
    in Unknown (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in (BlockListBlock) (created by WithFilters(BlockListBlock))
    in WithFilters(BlockListBlock) (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(WithFilters(BlockListBlock)) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(WithFilters(BlockListBlock))) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithViewportMatch(WithSelect(WithDispatch(WithFilters(BlockListBlock)))) (created by Pure(WithViewportMatch(WithSelect(WithDispatch(WithFilters(BlockListBlock))))))
    in Pure(WithViewportMatch(WithSelect(WithDispatch(WithFilters(BlockListBlock))))) (created by BlockList)
    in div (created by BlockList)
    in BlockList (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(BlockList) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(BlockList))
    in Unknown (created by VisualEditor)
    in div (created by CopyHandler)
    in CopyHandler (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(CopyHandler) (created by VisualEditor)
    in div (created by ObserveTyping)
    in ObserveTyping (created by WithSafeTimeout(ObserveTyping))
    in WithSafeTimeout(ObserveTyping) (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(WithSafeTimeout(ObserveTyping)) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(WithSafeTimeout(ObserveTyping))) (created by VisualEditor)
    in div (created by WritingFlow)
    in div (created by WritingFlow)
    in WritingFlow (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(WritingFlow) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(WritingFlow)) (created by VisualEditor)
    in div (created by BlockSelectionClearer)
    in BlockSelectionClearer (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(BlockSelectionClearer) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(BlockSelectionClearer)) (created by VisualEditor)
    in VisualEditor (created by Layout)
    in div (created by Layout)
    in div (created by FocusReturnProvider)
    in FocusReturnProvider (created by Layout)
    in Layout (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithViewportMatch(Layout) (created by NavigateRegions(WithViewportMatch(Layout)))
    in div (created by NavigateRegions(WithViewportMatch(Layout)))
    in NavigateRegions(WithViewportMatch(Layout)) (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(NavigateRegions(WithViewportMatch(Layout))) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(NavigateRegions(WithViewportMatch(Layout)))) (created by Editor)
    in ErrorBoundary (created by Editor)
    in div (created by DropZoneProvider)
    in DropZoneProvider (created by BlockEditorProvider)
    in SlotFillProvider (created by BlockEditorProvider)
    in BlockEditorProvider (created by Context.Consumer)
    in WithRegistry(BlockEditorProvider) (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(WithRegistry(BlockEditorProvider)) (created by EditorProvider)
    in EditorProvider (created by ComponentWithDispatch)
    in ComponentWithDispatch (created by Context.Consumer)
    in WithDispatch(EditorProvider) (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(WithDispatch(EditorProvider)) (created by Editor)
    in StrictMode (created by Editor)
    in Editor (created by ComponentWithSelect)
    in ComponentWithSelect (created by Context.Consumer)
    in WithSelect(Editor)

React will try to recreate this component tree from scratch using the error boundary you provided, BlockCrashBoundary.
    logCapturedError (react-dom.js:17206)
    logError (react-dom.js:17242)
    callback (react-dom.js:18183)
    callCallback (react-dom.js:16522)
    commitUpdateEffects (react-dom.js:16561)
    commitUpdateQueue (react-dom.js:16552)
    commitLifeCycles (react-dom.js:17453)
    commitAllLifeCycles (react-dom.js:18825)
    callCallback (react-dom.js:143)
    dispatchEvent
    invokeGuardedCallbackDev (react-dom.js:193)
    invokeGuardedCallback (react-dom.js:250)
    commitRoot (react-dom.js:19037)
    (anonyme Funktion) (react-dom.js:20507)
    unstable_runWithPriority (react.js:735)
    completeRoot (react-dom.js:20506)
    performWorkOnRoot (react-dom.js:20435)
    performWork (react-dom.js:20343)
    performSyncWork (react-dom.js:20317)
    interactiveUpdates$1 (react-dom.js:20584)
    dispatchInteractiveEvent (react-dom.js:4985)
    dispatchInteractiveEvent

1 个回复
最合适的回答,由SO网友:egolive 整理而成

我知道了。。。我只是错过了“wp editor”的排队。。。

下面是我的示例代码:

wp_register_script(
                \'mir-shortcodes-plugin-msc-rotating-icon-circle\',
                plugins_url($index_js, __FILE__),
                array(
                    \'wp-blocks\',
                    \'wp-i18n\',
                    \'wp-element\',
                    \'wp-components\',
                    \'wp-editor\'
                ),
                filemtime("$dir/$index_js")
            );

相关推荐

Testing Plugins for Multisite

我最近发布了一个WordPress插件,它在单个站点上非常有效。我被告知该插件在多站点安装上不能正常工作,我理解其中的一些原因。我已经更新了代码,现在需要一种方法来测试更新后的代码,然后才能转到实时客户的多站点安装。我有一个用于测试的WordPress安装程序的单站点安装,但需要在多站点安装上进行测试。根据我所能找到的唯一方法是在网络上至少有两个站点来安装整个多站点安装,以测试我的插件。设置WordPress的整个多站点安装是插件开发人员的唯一/首选方式,还是有更快的测试环境可用。