问题描述
我在registerBlockType-function中设置这些属性:
attributes: {
message: {
type: 'string',source: 'html',selector: 'div.content',},url: {
type: 'string',source: 'text',attribute: 'href',selector: 'a.link',bgImageId: {
type: 'string',attribute: 'src',selector: 'img',}
export default function Save( { attributes,className } ) {
return(
<div className={ className }>
<a href={ attributes.url } className={ 'link' }>
<div className={ 'content' }>{ attributes.message }</div>
<div><img src= { attributes.bgImageId } /></div>
</a>
</div>
);
}
但是重新加载编辑器后,出现多个错误:
Block validation: Expected attribute `href` of value `o`,saw `k`
Block validation: Block validation Failed for `custom/custom-blocks` (
Content generated by `save` function:
<div class="wp-block-custom-custom-blocks"><a href="o" class="link"><div class="content">o</div><div><img class="img"/></div></a></div>
Content retrieved from post body:
<div class="wp-block-custom-custom-blocks"><a href="k" class="link"><div class="content">o</div><div><img src="https://test.umana.ch/wp-content/uploads/image.png"/></div></a></div>
我尝试更改属性,但似乎无济于事。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)