Gutenberg:如何限制 InnerBlocks 中的块数

问题描述 投票:0回答:0
const innerBlocksCount = innerBlocks.length;
  if (innerBlocksCount > allowedBlocksCount) {
    innerBlocks.slice(0, allowedBlocksCount);

    return (
      <InnerBlocks renderAppender={() => false} innerBlocks={innerBlocks} />
    );

我正在尝试为 wordpresss 中的列块克隆,用户将选择 1 或 2 或 3 个块放入,我的块工作正常但是当用户放入 3 个块然后选择 1 时,我想要要删除的最后 2 个块,

我试过好几样东西,怎么才能达到那样的效果

wordpress wordpress-gutenberg
© www.soinside.com 2019 - 2024. All rights reserved.