我认为也可以使用useBlockProps管理包装器类。我在古腾堡官方文件中找到了这个解决方案,here
import { useBlockProps } from \'@wordpress/block-editor\';
// ...
const blockSettings = {
apiVersion: 2,
// ...
edit: () => {
const blockProps = useBlockProps( {
className: \'my-random-classname\',
} );
return <div { ...blockProps }>Your block.</div>;
},
};