如何解决如何在警报内按下时导航
当按下警报按钮时,我试图导航到另一个屏幕,但我不断收到错误“[错误:TransformError SyntaxError:D:\one\HomeScreen.js:意外标记,预期”,”(63:82 )” 下面是我的代码 请帮助我谢谢你们 一些随机词,所以我可以发布这个问题
class HomeScreen extends React.Component {
constructor(props) {
super(props);
this.state = {
input: {
username: null,email: null,password: null,confirm_password: null,},errors: {
username: null,};
this.handleSubmit = this.handleSubmit.bind(this);
}
handleSubmit = (event) => {
//event.preventDefault();
if (this.validate()) {
alert('ok');
console.log(this.state);
this.setState((prevState) => {
let input = Object.assign({},prevState.input);
input.username = null;
input.password = null;
input.email = null;
input.confirm_password = null;
return { input };
});
this.setState((prevState) => {
let errors = Object.assign({},prevState.errors);
errors.username = null;
errors.password = null;
errors.email = null;
errors.confirm_password = null;
return { errors };
});
Alert.alert('Đã Đăng Ký','Xin Hãy Đăng Nhập',[
{text: 'Cancel',onPress: () => console.log('Cancel Pressed'),style={styles.container}},{text: 'OK',onPress: () => this.props.navigation.navigate('List'),//code to navigate}
],{ cancelable: false });
}
}
解决方法
Nvm 我做了它只是删除了一个“,”这是警报中的代码
Alert.alert('Đã Đăng Ký','Xin Hãy Đăng Nhập',[
{text: 'Thoat',onPress: () => console.log('Cancel Pressed')},// {text: 'OK',onPress: () => this.props.navigation.navigate('List'),//code to navigate}
{text: 'Tien Len',onPress: () => this.props.navigation.navigate('List')}
],{ cancelable: false });
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。