reactjs - 导航在 React Native 中的 axios 调用中不起作用
问题描述
我正在使用axios
React Native 中的发布请求来执行登录用户功能。我已成功收到回复,但登录后我无法导航到主屏幕。这是我的代码。
axios.post('/wp-json/api/v1/user/do_login', {
username: username,
password: password
})
.then(function (response) {
console.log(JSON.stringify(response.data.type));
if(response.data.type == "success"){
alert("Login Successfully");
this.props.navigation.navigate("home");
}else if(response.data.type == "error"){
alert("Incorrect Detail");
}
})
.catch(function (error) {
console.log( JSON.stringify(response));
});
在上面的代码中,我成功地得到了响应,但没有得到下一个屏幕。这是我正在导航到下一个屏幕..
this.props.navigation.navigate("home");
解决方案
推荐阅读
- azure - 如何关闭 Azure API 管理策略上的 SSL 验证?
- javascript - 如何将函数传递给 nodejs-express 中的 express-handlebars?
- ms-access - 组合选项的选择性显示
- php - How to map a trait without any doctrine mapping in it?
- javascript - mocking store.getState()
- ios - 如何在本地存储使用 Alamofire 下载的对象
- python - tf.group_by_reducer 示例,reducer 中有列表
- windows - 批量移动脚本给出语法错误,不移动文件
- java - Use a String as a conditional in java (Convert String to boolean)
- python - 使用请求模块进行抓取时出现错误消息 10054