0 onchange textinput react-native
如果我在 textInput 中输入超过 10 个字符,我想要第二行。如果输入超过 5 个字符,我已经更改了文本的字体大小。这是工作正常。
但是如果我输入超过 11 个字符,它应该会出现在第二行
请帮我清除这个
这是我的代码...
_onChangeText(text) {
this.setState({ fontSize: (text.lenght > 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)
| 归档时间: |
|
| 查看次数: |
5268 次 |
| 最近记录: |