React native 你好是否有可能在本机视图中显示库图像。如果选择任何图像并更改配置文件图片?
我已经在使用“React native image picker”,但我想在视图中显示库图像。如果我选择图像,它将更改配置文件图像???检查此库: 您可以获取相册中的图像,并使用React native 你好是否有可能在本机视图中显示库图像。如果选择任何图像并更改配置文件图片?,react-native,React Native,我已经在使用“React native image picker”,但我想在视图中显示库图像。如果我选择图像,它将更改配置文件图像???检查此库: 您可以获取相册中的图像,并使用CameraRoll.getPhotos(params)将它们渲染到视图中 范例 _handleButtonPress = () => { CameraRoll.getPhotos({ first: 20, assetType: 'Photos', }) .th
CameraRoll.getPhotos(params)将它们渲染到视图中代码>
范例
_handleButtonPress = () => {
CameraRoll.getPhotos({
first: 20,
assetType: 'Photos',
})
.then(r => {
this.setState({ photos: r.edges });
})
.catch((err) => {
//Error Loading Images
});
};
render() {
return (
<View>
<Button title="Load Images" onPress={this._handleButtonPress} />
<ScrollView>
{this.state.photos.map((p, i) => {
return (
<Image
key={i}
style={{
width: 300,
height: 100,
}}
source={{ uri: p.node.image.uri }}
/>
);
})}
</ScrollView>
</View>
);
}
\u把手按钮按下=()=>{
CameraRoll.getPhotos({
第一:20,,
资产类型:“照片”,
})
.然后(r=>{
this.setState({photos:r.edges});
})
.catch((错误)=>{
//加载图像时出错
});
};
render(){
返回(
{this.state.photos.map((p,i)=>{
返回(
);
})}
);
}