Reactjs Can';t在URLInputButton(Gutenberg)中输入文本
我在Gutenberg中使用URLInputButton组件,但无法让它接受任何文本(键入时不会发生任何事情),即使我遵循包的github上的文档到了t 作为记录,URLInput本身工作正常,但是按钮带来的一个由于任何原因都不能工作Reactjs Can';t在URLInputButton(Gutenberg)中输入文本,reactjs,wordpress,jsx,wordpress-gutenberg,gutenberg-blocks,Reactjs,Wordpress,Jsx,Wordpress Gutenberg,Gutenberg Blocks,我在Gutenberg中使用URLInputButton组件,但无法让它接受任何文本(键入时不会发生任何事情),即使我遵循包的github上的文档到了t 作为记录,URLInput本身工作正常,但是按钮带来的一个由于任何原因都不能工作 const { InnerBlocks, URLInputButton, URLInput } = wp.blockEditor; const { Component, Fragment } = wp.element; const { __ } = wp.i18n
const { InnerBlocks, URLInputButton, URLInput } = wp.blockEditor;
const { Component, Fragment } = wp.element;
const { __ } = wp.i18n;
const TemplateImg = [
[ 'core/image' ],
[ 'core/heading' ],
[ 'core/paragraph' ],
];
class EditLinkImage extends Component {
constructor() {
super(...arguments);
this.render = this.render.bind(this);
}
render() {
const {
className,
attributes: { btnUrl, btnText },
setAttributes
} = this.props;
const onSelectURL = ( url, post ) => {
setAttributes( {
btnUrl: url,
btnText: (post && post.title) || 'Click here'
} );
};
return (
<Fragment>
<label>Choose a Link</label>
<URLInputButton
onChange={ onSelectURL }
value='asdfasd'
/>
<div className="feat-link">
<InnerBlocks
template={TemplateImg}
templateLock="all"
/>
</div>
</Fragment>
);
}
}
export default EditLinkImage;```
const{InnerBlocks,URLInputButton,URLInput}=wp.blockEditor;
const{Component,Fragment}=wp.element;
常数{{{}=wp.i18n;
常量模板img=[
[“核心/图像”],
[“核心/标题”],
[“核心/段落”],
];
类EditLinkImage扩展组件{
构造函数(){
超级(…参数);
this.render=this.render.bind(this);
}
render(){
常数{
类名,
属性:{btnUrl,btnText},
集合属性
}=这是道具;
const onSelectURL=(url,post)=>{
设置属性({
btnUrl:url,
btnText:(post&&post.title)| |'单击此处'
} );
};
返回(
选择一个链接
);
}
}
导出默认EditLinkImage```
您必须将URLInputButton
的值设置为value={btnUrl}
。如果你想知道更多,请阅读。找到答案!与URLInput组件不同,URLInputButton应该采用“url”属性,而不是“值”