【发布时间】:2019-04-19 15:19:02
【问题描述】:
设置样式属性正在使用它。
<Input
style={{ borderWidth: this.state.focused ? "4px" : "1px" }}
placeholder="this works"
onMouseEnter={() => this.setState({ focused: true })}
onMouseLeave={() => this.setState({ focused: false })}
/>
但是,当我使用Input 组件的后缀或前缀属性时,它不起作用。
<Input
style={{ borderWidth: this.state.focused ? "4px" : "1px" }}
placeholder="not this"
/*only difference is this suffix line*/
suffix={<Icon type="save" />}
onMouseEnter={() => this.setState({ focused: true })}
onMouseLeave={() => this.setState({ focused: false })}
/>
当我在浏览器上查看源代码时,它给了我原因。
1.案例:
<input placeholder="this works" type="text" class="ant-input" style="border-width: 1px;">
2.案例:
<span class="ant-input-affix-wrapper" style="border-width: 1px;"><input placeholder="not this" type="text" class="ant-input"><span class="ant-input-suffix"><i class="anticon anticon-save"></i></span></span>
2.case span块吸收样式的原因。
那么如何在具有后缀/前缀属性的输入上设置我的样式。
【问题讨论】:
标签: javascript reactjs input antd