Wordpress 将属性从父Gutenberg块传递给子Gutenberg块

Wordpress 将属性从父Gutenberg块传递给子Gutenberg块,wordpress,attributes,parent-child,wordpress-gutenberg,gutenberg-blocks,Wordpress,Attributes,Parent Child,Wordpress Gutenberg,Gutenberg Blocks,如何传递父属性或传递内部子块中的一些道具 例如,我想将此块属性添加到块08中,并将其作为内部块添加。将数据从父级传递到子级GUTENBERG 母公司 孩子 const {useSelect, dispatch, select} = wp.data; edit: (props) => { const { clientId } = props; var children = select('core/block-editor').getBlock

如何传递父属性或传递内部子块中的一些道具



例如,我想将此块属性添加到块08中,并将其作为内部块添加。

将数据从父级传递到子级GUTENBERG

母公司

孩子

const {useSelect, dispatch, select} = wp.data;

edit: (props) => {
    const {
        clientId
    } = props;

    var children = select('core/block-editor').getBlocksByClientId(clientId).[0].innerBlocks;
    children.forEach(function(child){
        dispatch('core/block-editor').updateBlockAttributes(child.clientId, {label: 'Hello'})
    });
let parent = select('core/block-editor').getBlockParents(clientId);
const parentAttributes = select('core/block-editor').getBlockAttributes(parent);
console.log(parentAttributes); // Block Attributes
console.log(props.attributes.label); // Passing Props