javascript - Uncaught (in promise) TypeError: o is not a function at this.setState
问题描述
我在 this.setState 中遇到错误。我必须绑定功能吗?还是有语法问题?有人可以帮忙吗?
componentDidMount() {
let mobile = false;
this.setState({
displayZipSearchPage : true,
geolocation: {
latitude: null,
longitude: null,
shared: false,
supported: false,
},
});
if (isNotEmptyObject(window) && 'navigator' in window) {
if ('geolocation' in window.navigator) {
navigator.geolocation.getCurrentPosition(
(pos) => {
this.setState({ 'The error occurs here'
geolocation: {
latitude: pos.coords.latitude.toString(),
longitude: pos.coords.longitude.toString(),
shared: false,
supported: true,
},
});
},
console.error,
this.geoOptions,
);
}
}
}
解决方案
推荐阅读
- r - 如何使用summary 和group_by?
- powershell - Export-csv 返回 1 个实例而不是整个结果
- javascript - 删除“编辑”文本单击“删除”文本
- amazon-web-services - AWS CLI:如何设置新复制实例的 VPC
- sql-server - 以整数值作为日期参数的 T-SQL 日期函数
- protocol-buffers - 多个原型中的 FileOptions 扩展
- ajax - 如何在 laravel 中使用 ajax 使用搜索栏?
- javascript - 简单立方体场景中的颗粒纹理
- google-apps-script - 我在 Regexp 获取表达式时遇到错误
- javascript - React - 单击第三个组件时更新多个组件的状态