我正在尝试使用服务器端渲染创建古腾堡块。问题是块渲染在左上角。在前端,它按预期显示。
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const el = wp.element.createElement;
registerBlockType( \'wda-wda/wda-gutenberg-block\', {
title: __( \'My Block\', \'wda-wda\' ),
icon: \'admin-users\',
category: \'common\',
attributes: {
images : {
default: [],
type: \'array\',
}
},
edit( { attributes, setAttributes, className, focus, id } ) {
// Put a user interface here.
return null;
},
save( { attributes, className } ) {
// Gutenberg will save attributes we can use in server-side callback
return null;
},
} );
和PHP:
function wda_register_block() {
register_block_type( \'wda-wda/wda-gutenberg-block\', array(
\'editor_script\' => \'wda-gutenberg-block\',
\'render_callback\' => array( $this, \'render_callback\' ),
) );
}
function render_callback() {
echo \'The Content\';
}
add_action( \'init\', \'wda_register_block\');
内容显示在帖子编辑器的左上角:
http://cloud.supportally.com/736abefe6221是否应手动调整?