我正在尝试扩展在 Tasty Recipes 插件中注册的现有块。我在侧边栏添加了一个控件来处理给定饮食类型的选择,但是当选择一个选项时,会显示以下错误:
加载块时出错:无效参数:属性
目前在 WordPress 5.2.1 上运行,我正在尝试扩展Tasty Recipes 插件
/**
* Add custom attribute to store diet type
*/
var addCustomAttributes = function( settings, name ) {
if ( name !== 'wp-tasty/tasty-recipe' ) {
return settings;
}
settings.attributes = Object.assign( settings.attributes, {
dietType: {
type: 'string',
// ? Setting default here causes break
},
} );
return settings;
}
wp.hooks.addFilter( 'blocks.registerBlockType', 'wp-tasty/tasty-recipe', addCustomAttributes );
/**
* Create HOC to add diet type control to inspector controls …Run Code Online (Sandbox Code Playgroud)