1 font-size textinput react-native
我想仅在 charLength 大于 6 时更改我们在 textInput 中输入的文本的字体大小。
实际字体大小为 80px,更改时应为 40 或小于等于
提前致谢
您可以为TextInput组件提供条件样式。
例子
_onChangeText(text) {
this.setState({ fontSize: text.length > 6 ? 40 : 80 });
}
render() {
return (
// Giving an array of objects to style property can help you to define a -- default value
<TextInput
onChangeText={this._onChangeText.bind(this)}
style={[ {fontSize: 80}, {fontSize: this.state.fontSize} ]}
/>
)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22243 次 |
| 最近记录: |