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

韩靖琪
2023-12-01
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);
})
 类似资料: