【发布时间】:2021-08-17 10:23:18
【问题描述】:
我正在使用带有 MapView 及其组件的 typescript,我需要知道要放入界面的 mapView 和标记的类型,
这是代码,
interface SelectInput {
style?: StyleProp<ViewStyle>;
isMapSelector?: boolean;
isModalVisable?: boolean;
markerLocation?: MarkerProps ; // What sould I type here
initialRegion?: MapViewProps; // What sould I type here
onMapViewOress?: () => object;
onOpen: () => void;
onClose: () => void;
}
<MapView
initialRegion={initialRegion} //Warining under initialRegion
onPress={onMapViewOress}
style={{flex: 1}}>
<Marker coordinate={markerLocation} /> //Warining under coordinate
</MapView>
这就是我在 initialRegion 下出现的警告, “没有超载匹配这个调用。 重载 1 of 2,'(props: MapViewProps | Readonly): MapView',给出了以下错误。 输入'MapViewProps | undefined' 不可分配给类型 'Region |不明确的'。 “MapViewProps”类型缺少“Region”类型的以下属性:纬度、经度、纬度三角洲、经度三角洲”
这就是我在坐标下出现的警告, “没有超载匹配这个调用。 Overload 1 of 2, '(props: MarkerProps | Readonly): Marker',给出了以下错误。 输入'MarkerProps | undefined' 不可分配给类型 'LatLng |动画区域”。 类型“未定义”不可分配给类型“LatLng |动画区域'。”
【问题讨论】:
标签: reactjs typescript react-native interface