我有一些像这样的代码用于获取用户位置 getLocaiton 是一个 onclick 侦听器:
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(setLocation, errorLocation);
} else {
alert('error')
}
}
let errorLocation = (error) => {
console.log(error)
}
let setLocation = (location) => {
try {
console.log('ok')
console.log(location.coords)
} catch (e) {
}
}
我在 errorLocation() 函数中得到了这个错误
The permission was revoked