Javascript 为什么地理定位在移动浏览器和桌面上不起作用?
我正试图通过HTML5地理定位获得用户的位置。在“桌面”上,当我在授予访问权限2:网络位置提供程序时出现此错误https://www.googleapis.com/':没有收到任何回应。当我在手机上测试时,它不会问访问问题,错误1:用户拒绝地理定位 这是我的代码:Javascript 为什么地理定位在移动浏览器和桌面上不起作用?,javascript,vue.js,geolocation,Javascript,Vue.js,Geolocation,我正试图通过HTML5地理定位获得用户的位置。在“桌面”上,当我在授予访问权限2:网络位置提供程序时出现此错误https://www.googleapis.com/':没有收到任何回应。当我在手机上测试时,它不会问访问问题,错误1:用户拒绝地理定位 这是我的代码: successHandler(position) { console.log(position) alert(position.coords.latitude) alert(position.coords.longitud
successHandler(position) {
console.log(position)
alert(position.coords.latitude)
alert(position.coords.longitude)
},
errorHandler(errorObj) {
alert(errorObj.code + ": " + errorObj.message);
},
getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(this.successHandler, this.errorHandler, {
enableHighAccuracy: true,
maximumAge: 10000,
timeout: 10000
})
} else {
alert("Geolocation is not supported by this browser.");
}
}
created() {
this.getLocation()
},
我在所有设备上都使用谷歌浏览器
您的网站是否通过HTTPS提供服务?此功能仅在安全上下文中可用这是vue.config.js文件中的my codemodule.exports={devServer:{https:true}}