javascript - 值不能从 ReadableNativeMap 转换为 double

标签 javascript android react-native variables marker

我有一个自定义标记图像,并想使用一个变量来表示图像的不透明度。我执行以下操作并遇到此错误“无法将不透明度的值从 ReadableNativeMap 转换为加倍”

var status=1;

  <MapView.Marker
         key={marker.latitude}
         coordinate={{ latitude: marker.latitude, longitude: marker.longitude }} 
         onPress={() => this.props.Quiz2(marker.latitude, marker.longitude)} >
    <View><Image source={require('../assets/icons/quiz.png')} style={{ width: 40, height: 40,opacity:status}}/></View>
</MapView.Marker>

最佳答案

您必须使用 <Animated.*>例如

对于 <View>使用 <Animated.View>
对于 <Image>使用 <Animated.Image>
等等。如果在 Animated.* 中使用,React Native 会理解 Animated.Value零件。

关于javascript - 值不能从 ReadableNativeMap 转换为 double,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54272759/

相关文章:

Javascript 井字游戏 : how to alert user that he won?

javascript - m.facebook.com 如何能够运行原生移动操作,如相机和图库?

Android:来自 BroadcastReceiver 的通知

Javascript 集合 vs 数组 vs 对象定义

javascript - 在 Android 服务中运行 JavaScript

java - Android上基于STM和Actor的选项/库

reactjs - 在 react 导航 v5 上使用带有 useRoute 的 typescript

reactjs - View 在被 TouchableOpacity 包裹后部分隐藏

javascript - react 原生 : set id to a component and get this component's id

javascript - 使用 z-index 那么为什么在 html 中显示背景对象