未被捕获的TypeError:无法在geoLocationInit读取未定义的属性'getCurrentPosition'

时间:2018-07-26 08:55:20

标签: javascript

尝试获取用户的当前位置时出现以下错误,这是控制台中显示的内容

  

jquery-3.3.1.min.js:2未捕获的TypeError:无法读取未定义的属性'getCurrentPosition'       在geoLocationInit(google.js:8)       在HTMLDocument。 (google.js:5)       在l(jquery-3.3.1.min.js:2)       在c(jquery-3.3.1.min.js:2)

public class hello {
    static Boolean flag = false;
    public static void main(String args[]) throws InterruptedException {
        MyThread t = new MyThread();
        t.start();
        Thread.sleep(3000);
        hello.flag = true;
    }
    static class MyThread extends Thread {

        public void run(){
            System.out.println("Thread start");
            while(true){
                if(hello.flag){
                    break;
                }
            }
            System.out.println("Thread end");//why not print this statement? but run in debug mode, it will print this statement correctly
        }

    }

}

1 个答案:

答案 0 :(得分:1)

只需将navigator.geoLocation.getCurrentPosition更改为navigator.geolocation.getCurrentPosition