1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| const mobilePosition = {
| state: {},
| mutations: {
| GET_NOWPOSITION(state, val) {
| let outData =
| val ||
| function (res) {
| console.log(res);
| };
| if (navigator.geolocation) {
| console.log("支持navigator.geolocation-111111111111111");
| try {
| navigator.geolocation.getCurrentPosition(function (position) {
| console.log(position);
| var lat = position.coords.latitude;
| var lon = position.coords.longitude;
| console.log("成功返回经纬度信息");
| console.log(lon, lat);
| outData([lon, lat]);
| });
| } catch {
| console.log("支持navigator.geolocation-需要HTTPS");
| }
| } else {
| console.log("不支持navigator.geolocation");
| return "不支持navigator.geolocation";
| }
| },
| },
| actions: {},
| };
|
| export default mobilePosition;
|
|