날씨 앱을 사용하고 있는데 getCoords 함수가 활성화되면 '나를 찾습니다!' 나는 그것이주는 결과에서 행복으로JS - geolocation 함수 오류, 모든 작업이 정상적으로 작동합니다.
getCoords(e){
e.preventDefault();
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition((position) =>{
const long = position.coords.longitude,
lat = position.coords.latitude;
console.log(`long ${long} and lat ${lat}`);
this.setMessage('http://api.openweathermap.org/data/2.5/forecast?lat='+lat+'&lon='+long+"&APPID=mykey");
}).bind(null,this);
}
}
와 나는 나를 조금 걱정 느낌 콘솔에서 오류를 많이 얻을 기대로 작업을 수행 버튼을 클릭합니다. 파이어 폭스 :
TypeError: navigator.geolocation.getCurrentPosition(...) is undefined
크롬과 오페라 :
Uncaught TypeError: Cannot read property 'bind' of undefined at WeatherApp.getCoords (app.bundle.js?49cb1f92ba06aee2ea42:374)
오페라 :
Failed to load resource: the server responded with a status of 404 (Not Found)
'.getCurrentPosition()'함수는 다른 함수를 반환하지 않지만 코드는 마치 마치 마치 함수처럼 쓰여집니다. – Pointy