小编Jim*_*dev的帖子

在古腾堡自定义横幅块中使用页面标题

我为古腾堡创建了一个自定义横幅图像块,效果很好,但是我想知道在编辑之前是否可以将页面标题用作当前横幅文本占位符?

在此处输入图片说明

我的编辑功能是

 return [
            el('div', {className:'header-banner'},
                el(
                    element.Fragment,
                    null,
                    controls,
                    el( "div",{
                        className: 'banner-image',
                        style: { backgroundImage: 'url('+attributes.mediaURL+')' }
                    },
                    attributes.title || isSelected ?  el(RichText, {
                            key: 'editable',
                            tagName: "h1",
                            className: "banner-title",
                            //Can i add the page title in here if it is avaiable??
                            //placeholder: i18n.__('Write title…'),
                            value: attributes.title,
                            onChange: function onChange(value) {
                                return props.setAttributes({ title: value });
                            },
                            inlineToolbar: true
                        }) : null 

                    )
                )
            )//header-banner
        ];    
Run Code Online (Sandbox Code Playgroud)

谢谢 :)

javascript wordpress wordpress-gutenberg

7
推荐指数
1
解决办法
939
查看次数