如何在警报中导航



当我按下警报按钮时,我试图导航到另一个屏幕,但我一直得到错误"[Error: TransformError SyntaxError: D:one homesscreen .js: Unexpected token, expected ","](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,
email: null,
password: null,
confirm_password: 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 });
}
}

我只是去掉了一个","下面是alert

中的代码
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 });

相关内容

  • 没有找到相关文章

最新更新