问题描述
我基本上是在创建Custom Carousel Gutenberg Block。它应该是前端的旋转木马,我计划使用gallery Block将图像添加到旋转木马。
轮播将使用bxSlider加载,这需要某种语法,如您所见here。画廊在前端(基于列表的图像输出)呈现不同的语法。我想修改渲染图库的语法。
render_callback
参数似乎修改了输出,但要使其正常工作,我需要图库中所有图像的ID。
我发现最接近的解决方法是in this thread使用数据模块和withdispatch
组件来检索数据,但是我不知道如何在JSX脚本中使用它。这是我的自定义块的脚本-
const { registerBlockType } = wp.blocks;
const { InnerBlocks } = wp.blockEditor;
const ALLOWED_BLOCKS_galLERY = ['core/gallery'];
const galLERY_TEMPLATE = [
['core/gallery',{} ]
];
registerBlockType('my-plugin/my-plugin-carousel',{
title: 'Carousel',description: 'Insert a Carousel using Images from gallery',category: 'common',icon: {
src: 'image-flip-horizontal',foreground: '#1d7eb6'
},attributes: {},edit: (props) => {
return([
<div className="my-carousel-container">
<InnerBlocks allowedBlocks={ ALLOWED_BLOCKS_galLERY } template={ galLERY_TEMPLATE } templateLock="insert"/>
</div>
])
},save: () => {
return <InnerBlocks.Content />
}
});
我们将非常感谢您提供任何有关如何处理这种情况的帮助!我花了最后两天的时间,对此无可奉告。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)