我正在尝试使用AlertIOS来显示消息,我在下面收到错误消息。警报框的代码嵌套在View和可触摸的高亮显示下方。调用AlertIOS组件是否存在嵌入其他组件的问题?
var TabOption = React.createClass({
deleteConnection: function(){
AlertIOS.alert('Connection Removed',
'We are no longer helping you on this account',
[{text: ''}]);
});
render:function(){
return(
<View style={{flex: 1,flexDirection: 'column',backgroundColor: 'white'}}>
<TouchableHighlight onPress={this.deleteConnection} style={styles.tabOptionContainer}>
<Text> Disconnect </Text>
</TouchableHighlight>
</View>
}
});
var styles = StyleSheet.create({
tabOptionContainer: {
width:Dimensions.width,
height:50,
justifyContent:'center',
alignItems:'center',
backgroundColor:'white',
}
});
错误:
Tried to display alert view but there is no application window. args: {
buttons = (
{
0 = "\Ud83d\Ude1e";
}
);
message = "We are no longer helping you on this account";
title = "Connection Removed";
type = default;
}
谢谢!
答案 0 :(得分:0)
好的,您的代码中存在一些语法错误。
这是您的代码,完全相同但已更正(ES6语法)
class TabOption extends Component {
constructor(props) {
super(props);
}
deleteConnection = () => {
AlertIOS.alert('Connection Removed',
'We are no longer helping you on this account',
[{text: ''}]);
};
render() {
return(
<View style={{flex: 1,flexDirection: 'column',backgroundColor: 'white'}}>
<TouchableHighlight onPress={this.deleteConnection} style={styles.tabOptionContainer}>
<Text> Disconnect </Text>
</TouchableHighlight>
</View>
);
};
}
const styles = StyleSheet.create({
tabOptionContainer: {
width:Dimensions.width,
height:50,
justifyContent:'center',
alignItems:'center',
backgroundColor:'white',
}
});
我为您here
设置了一个工作示例