问题描述
我正在使用 botframework 网络聊天,使用 react 来设计我们的机器人。我们需要突出显示从之前的自适应卡中选择的用户选择。我尝试了很多方法,但一无所获。有什么办法可以得到吗?
例如 我选择了“银行密钥请求”,然后选择了“更改”,但没有区别。选择后所有按钮也一样。
解决方法
我们可以为按钮颜色使用状态,然后在按下按钮时更新该状态
this.state = {
buttonColor:'red'
}
然后在 Button 组件中,将 buttonColor 状态置于 style 中
<Button onPress={()=> this.setState(buttonColor:"Blue")} style={{ color:this.state.buttonColor}} />
如果你使用的是react-native-adaptive-cards,你可以自定义样式如下
customThemeConfig = {
input: {
borderColor: "#000000",backgroundColor: "#F5F5F5",borderRadius: 4,borderWidth: 1,},button: {
"ios": {
color: 'white',backgroundColor: "#1D9BF6","android": {
color: 'white',"windows": {
color: 'white',}
}
}
<AdaptiveCards themeConfig={customThemeConfig} payload={payload} />
所以每当按钮被按下时,状态会改变颜色会变成蓝色。