我不是在gutenberg块中添加样式表

时间:2019-05-09 09:59:29

标签: wordpress-gutenberg

我的创建块未显示...

const {__} = wp.i18n;

const {registerBlockType} = wp.blocks; const {RichText} = wp.editor;

registerBlockType('block-examples / block-example-03-editable-block',{     标题:__('MonnyEditabale Block'),

icon: 'star-filled',

category: 'layout',

attributes: {
    label: {
      type: 'string',
      source: 'html',
      selector: '.label'
    },
    title: {
      type: 'string',
      source: 'html',
      selector: '.title'
    }
},

edit: ( props ) => {
    const { attributes: { content }, setAttributes, className } = props;
    const onChangeContent = ( newContent ) => {
        setAttributes( { content: newContent } );
    };
    return (
        <RichText
            tagName="p"
            className={ className }
            onChange={ onChangeContent }
            value={ content }
        />
    );
},
save: function(props) {
    const { label, title } = props.attributes

    return (
      <div>
        <div className="label">
          <RichText.Content
            value={ label }
          />
        </div>
        <div className="title">
          <RichText.Content
            value={ title }
          />
        </div>
      </div>
    )
  }

});

1 个答案:

答案 0 :(得分:0)

您也需要将块脚本排入php中的正确位置。阅读有关howto create your first block的非常出色的块编辑器手册。