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, // --->是否获取更精确的位置 true/false
timeout: 5000, // --->请求超时时间,单位ms;
maximumAge: 0
}