每当我导入Button
组成部分
import { Button } from "@wordpress/components";
。。。然后将其与variant
:if (attributes.imageId) {
return (
<Button variant="secondary" onClick={open}>
Change image
</Button>
);
}
return (
<Button variant="secondary" onClick={open}>
Select image...
</Button>
);
它从不呈现为变体:我确信这应该根据以下文档进行不同的渲染:https://developer.wordpress.org/block-editor/reference-guides/components/button/
应该是这样的:It also doesn\'t work if I use variant="primary"
<Button>Test</Button>
<button>Test</button>
您可以看到默认按钮与wordpress按钮:我做错了什么?包裹json依赖项:
"dependencies": {
"@wordpress/block-editor": "^7.0.2",
"@wordpress/blocks": "^11.1.0",
"@wordpress/i18n": "^4.2.2"
},
"devDependencies": {
"@wordpress/scripts": "^18.0.1"
}