react-native - 单击时更改可触摸不透明度内的文本
问题描述
我想将我的可触摸不透明度中的文本更改为新闻事件中的另一个文本。下面是我的代码
<TouchableOpacity
disabled={this.state.ButtonStateHolder}
onPress={this.onPressConfirm}
style={styles.button}
>
<View
style={[
styles.button1,
{
backgroundColor: this.state.ButtonStateHolder
? "#607D8B"
: "#8c0d04"
}
]}
>
<Text style={styles.buttontext}>Confirm</Text>
</View>
</TouchableOpacity>
在这里,我想将文本确认更改为 Parked on press event。我怎么做
解决方案
您必须将状态文本初始化为'Confirm'
. TouchableOpacity 将是这样的:
<TouchableOpacity
disabled={this.state.ButtonStateHolder}
onPress={() => {this.setState({text: 'Parked'})}}
style={styles.button}
>
<View
style={[
styles.button1,
{
backgroundColor: this.state.ButtonStateHolder
? "#8c0d0488"
: "#8c0d04ff"
}
]}
>
<Text style={styles.buttontext}>{this.state.text}</Text>
</View>
</TouchableOpacity>
推荐阅读
- javascript - 使用按钮增加表单的输入值(React Forms)不起作用
- highcharts - Highchart 在工具提示点格式中访问 series.data
- tensorflow - 关于从 TensorFlow 中的 GradientTape.gradient 获取 None 的问题
- ios - 将使用私有 API 'value(forKey: "view") 作为?UIView' 获得 App Store 拒绝
- python - 当我按下一个键时,如何让图片出现?
- python - 使用 python 和 selenium 使用图像的“src”属性下载图像
- python - 单击一个弹出窗口的按钮
- sql-server - 使用 Case 语句匹配单行上的多个值
- c# - 更改派生类的字段类型
- ms-access - 使用非 Access 后端时,如何让 Access 列出列过滤器中的可用值?