我已经在插件主/索引 php 文件中注册了自定义块。
register_block_type('gutenberg-custom/show-information', array(
'editor_script' => 'gutenberg-show-information',
'style' => 'gutenberg-customblock-css',
));
我想将此 PHP 文件中的一些数据发送到包含该块的实际实现的 js 文件。原因是,我需要从 PHP 进行 API 调用,并在 js 代码的选择框选项中使用该响应。请参阅下面的注释代码。这是js的代码。
edit: function(props) {
console.log("props", props);
return el(
Fragment,
{},
el(
InspectorControls,
{},
el(
PanelBody,
{ title: "Show Settings", initialOpen: true },
el(
PanelRow,
{},
el(SelectControl, {
label: "Select Exhibitor",
options: [ // **these options are static I have given but I want these to be dynamic coming from the plugin main file or can be any PHP file
{ label: "Big", value: "100%" },
{ label: "Medium", value: "50%" },
{ label: "Small", value: "25%" }
],
onChange: value => {
props.setAttributes({ exhibitor_id: value });
},
value: props.attributes.exhibitor_id
})
)
)
),
el(
"div",
{},
"[show-information]"
)
);
},