getLocation(){
if (navigator.geolocation){
let geolocation = navigator.geolocation;
geolocation.getCurrentPosition((position)=>{
alert(position.coords.longitude)
},(error)=>{
switch (error.code) {
case error.PERMISSION_DENIED:
break;
case error.POSITION_UNAVAILABLE:
break;
case error.TIMEOUT:
break;
case error.UNKNOWN_ERROR:
break;
}
},this.options);
}
}
options :{
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-14756.html