如何在 React Native 中在新闻中弹出图像
How to popup an image on press in react native
我想在印刷机上放大图像。
这是我的代码
{
this.state.data.file_name &&
<Avatar
xlarge
source={{ uri: IMG_URL + this.state.data.file_name }}
onPress={() => this.enlargeImage(IMG_URL +
this.state.data.file_name)}
activeOpacity={0.7}
containerStyle={{ borderWidth: 1, borderColor: '#000', margin: 10 }}
/>
}
enlargeImage = (img) => {
return (
<Lightbox underlayColor="white">
<Image
style={{flex: 1,height: 200}}
resizeMode="contain"
source={{ uri: img }}
/>
</Lightbox>
)
}
现在点击图片没有反应。我正在使用 react native lightbox
。有没有其他方法可以在触摸时弹出图像?
您必须将灯箱添加到主头像图像
示例:-
{this.state.data.file_name &&
<Lightbox style = {{flex: 1}}>
<Avatar
xlarge
source={{ uri: IMG_URL + this.state.data.file_name }}
activeOpacity={0.7}
containerStyle={{ borderWidth: 1, borderColor: '#000', margin: 10 }}
/>
</Lightbox>
}
头像不需要添加按下事件
lightbox会自动拍下活动
额外的样式,可以使用灯箱的属性。
我想在印刷机上放大图像。
这是我的代码
{
this.state.data.file_name &&
<Avatar
xlarge
source={{ uri: IMG_URL + this.state.data.file_name }}
onPress={() => this.enlargeImage(IMG_URL +
this.state.data.file_name)}
activeOpacity={0.7}
containerStyle={{ borderWidth: 1, borderColor: '#000', margin: 10 }}
/>
}
enlargeImage = (img) => {
return (
<Lightbox underlayColor="white">
<Image
style={{flex: 1,height: 200}}
resizeMode="contain"
source={{ uri: img }}
/>
</Lightbox>
)
}
现在点击图片没有反应。我正在使用 react native lightbox
。有没有其他方法可以在触摸时弹出图像?
您必须将灯箱添加到主头像图像
示例:-
{this.state.data.file_name &&
<Lightbox style = {{flex: 1}}>
<Avatar
xlarge
source={{ uri: IMG_URL + this.state.data.file_name }}
activeOpacity={0.7}
containerStyle={{ borderWidth: 1, borderColor: '#000', margin: 10 }}
/>
</Lightbox>
}
头像不需要添加按下事件 lightbox会自动拍下活动
额外的样式,可以使用灯箱的属性。