新版本react-native中使用定位遇到坑

yarn add @react-native-community/geolocation --save 或 npm install @react-native-community/geolocation --save
import geolocation from "@react-native-community/geolocation"


// 然后使用
navigator.geolocation = geolocation;
navigator.geolocation.getCurrentPosition((pos) => {
    let coords = pos.coords;
    // 打印经度-维度
    alert(coords.longitude + "," + coords.latitude);
})

你可能感兴趣的:(javascript,web,react,native)