【发布时间】:2019-07-29 06:17:37
【问题描述】:
所以我有一个 TextInput 并且占位符有一个样式。
为此,我将Text 与position: 'absolute' 和zIndex: 1 放在TextInput 之前
activeField(){
this.setState({active: true})
}
render(){
return(
{ !this.state.active &&
<Text style={STYLES.textInputPlaceholder}>
{this.props.placeholder}
</Text>
}
<TextInput
style={STYLES.textInputField}
onFocus={() => this.activeField()}
/>
)
}
现在,带有占位符的Text组件,当我按下它时,我应该可以按下占位符,也就是这里的Text组件,并且可以调用TextInput的onFocus方法
我希望我能够清楚地解释我的问题。
【问题讨论】:
-
嗨,Shubham,在下面试试我的解决方案。那应该对你有帮助:)
标签: reactjs react-native react-native-textinput react-native-text