RNImage Picker说:“然后,如果您想在render()方法中显示此图像:”但这是默认功能。如何在屏幕上显示图像?
export default function Expenses(){
const [ imageSource, setImageSource ] = useState(null);
const [ data, setData ] = useState(null);
uploadImage = async () => {
ImagePicker.showImagePicker(options, (response) => {
console.log('Response = ', response);
if (response.didCancel){
console.log('User cancelled image picker');
} else if (response.error){
console.log('ImagePicker Error: ', response.error)
} else if (response.customButton){
console.log('User tapped custom button: ', response.customButton);
} else {
const source = { uri: response.uri };
setImageSource({
imageSource: source
});
}
})
};
我使用的是样式组件,而Photo使用的是样式图像。
return (
<Container>
<Photo source={imageSource} />
<ButtonTouch
onPress={uploadImage}>
<TextButton>Select Image</TextButton>
</ButtonTouch>
</Container>
);
}
让我简化一下。我正在尝试将此照片保存在手机存储中或拍照,然后将其显示在屏幕上。但我无法显示。什么也没返回。