无法将ReadableNativeMap转换为double类型的值

8

我有一个自定义标记图片,想要使用变量来控制图片的透明度。我尝试了以下代码,但出现了错误:"无法将可读本地映射转换为双精度浮点数作为不透明度的值"

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>


请使用 status = 1.0 - Juorder Gonzalez
4
你尝试使用 Animated.Image 替代 Image 了吗? - Mher
1个回答

10

你需要使用<Animated.*>,例如:

对于<View>,请使用<Animated.View>

对于<Image>,请使用<Animated.Image>

以此类推。如果在Animated.*组件中使用了Animated.Value,则React Native会理解它。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接