【发布时间】:2019-03-17 22:06:20
【问题描述】:
我已按照 react-native-maps 文档中的指南进行操作:我收到了错误。
我在 stackoverflow 和 google 上到处查看,但找不到解决方法。
我尝试了所有可以在论坛上找到的答案,但仍然出现错误。
错误:
Invariant Violation:requireNativeComponent:在 UIManager 中找不到“AIRMap”。
我的代码:
import React from 'react';
import MapView from 'react-native-maps';
import { StyleSheet } from 'react-native';
export default class App extends React.Component {
constructor() {
super();
this.state = {};
}
render() {
return (
<MapView
style = {styles.map}
showsUserLocation = {false}
followUserLocation = {false}
zoomEnabled = {true}
/>
)
}
}
const styles = StyleSheet.create ({
map: {
height: 400,
marginTop: 80
}
})
【问题讨论】:
-
您是要在 iOS、Android 或两者上运行吗?
-
目前我只在 iOS 上尝试过
-
抱歉耽搁了。你是如何链接“react-native-maps”的?如果您将
react-native link react-native-maps与 npm 一起使用,请确保使用--save标签安装它。 -
我使用了
react-native link react-native-maps。但是我用的是yarn,所以不用加--save吧? -
它应该是这样工作的,但是文档只在运行安装后脚本的上下文中提到了纱线。
标签: react-native