问题:IOS系统首次进入页面,有进if (navigator.geolocation){}添加,但没有执行 navigator.geolocation.getCurrentPosition(this.showPosition.bind(this), this.showError.bind(this), options);
没进入showPosition(),也没有进入showError()事件
安卓机正常,不会出现这个问题
代码:
if(navigator.geolocation){
console.log(navigator.geolocation);
alert(1);
const options = {
enableHightAcuracy: false, // 指示浏览器获取高精度的位置,默认为false
timeout: 6000, // 指定获取地理位置的超时时间,默认不限时,单位为毫秒
maximunAge: 30000 // 最长有效期,在重复获取地理位置时,此参数指定多久再次获取位置。
};
navigator.geolocation.getCurrentPosition(this.showPosition.bind(this), this.showError.bind(this), options);
} else {
console.log('该浏览器不支持获取地理位置');
alert('该浏览器不支持获取地理位置');
this.cityName = sessionStorage.getItem(COMMON.CITY_NAME);
this.goPage();
}
加个window.onload