我正在使用web的react-native-maps,并且不断收到我无法解决的错误。我已经尝试了在互联网上找到的所有内容。
这是我遇到的错误,此错误在react-native-map包中。
./node_modules/react-native-maps/lib/components/MapCallout.js
SyntaxError: /home/vishal/Desktop/tracker-app/tracker/node_modules/react-native-maps/lib/components/MapCallout.js: Unexpected token (31:11)
29 | render() {
30 | const AIRMapCallout = this.getAirComponent();
> 31 | return <AIRMapCallout {...this.props} style={[styles.callout, this.props.style]} />;
| ^
32 | }
33 | }
34 |
这就是我要使用react-native-map展示的内容
import React, { Component } from "react";
import { StyleSheet, Text, View } from "react-native";
import MapView from "react-native-maps";
class Map extends Component {
render() {
return (
<View style={styles.container}>
<Text>in map.js</Text>
<MapView
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421
}}
style={styles.map}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
},
map: {
width: "100%",
height: "100%"
}
})
export default Map;
答案 0 :(得分:0)
我今天遇到了同样的问题,并使用react-native-web-maps解决了这个问题:https://github.com/react-native-web-community/react-native-web-maps
只需安装:npm install react-native-web-maps --save
并在您的Webpack配置中为其添加别名:'react-native-maps': 'react-native-web-maps'