如何使用导航版本5将捕获的图像从本机相机传递到另一个屏幕

问题描述

我遵循了它起作用的文档,但是使用捕获后返回的图像数据不会出现在新屏幕上。我已经搜索过但没有任何导航图像数据的解决方案。

this is the code for passing the image data to the next screen,alongside a test

the screen for receiving the captured image

receiving the captured image in an image component

passing image data to state(path and pathBase64)

解决方法

使用此代码导航到屏幕,此处imageFile是从相机捕获后存储图像的状态。

props.navigation.navigate("navigation_route",{image: imageFile})

然后,使用此代码在另一个屏幕上获取图像。

let image = props.navigation.getParam('image')
,

要在下一个屏幕中接收图像,请使用以下代码

let image = props.route.params.image
,

屏幕发送图像 函数:navigation.navigate('RouteName',{imageTobeTransferred:
state.imageInBase64})

接收屏幕。 const {imageTobeTransferred} = route.params; 返回( data:image/jpeg;base64,${imageTobeTransferred}}} /> )

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...