【发布时间】:2021-05-01 16:51:30
【问题描述】:
我有一个自定义组件,它接受一个属性图标并将按钮的内部图像设置为相应的图标,如下所示:
<custom-button-icon ref={showIcon} slot="right" icon="tier1:visibility-show" onClick={() => isPasswordVisible(false)} />
我想使用 styled-components 对该组件的几个实例应用自定义样式。如何传递 icon 道具以使其仍然起作用(作为custom-button-icon 的弹出窗口传递)?这是我目前所拥有的,但它返回一个空按钮(没有图标):
export const d2lButtonIcon = ({ icon }) => {
const buttonIcon = styled(`d2l-button-icon`)`
display: flex;
align-items: center;
justify-content: center;
padding: 100px;
margin: 1px;
`
return <buttonIcon icon={icon} />
}
谢谢!
【问题讨论】:
标签: reactjs button components styled-components