小编Ale*_*hez的帖子

无法显示来自反应本机视觉相机的临时文件的图像

我正在通过构建一个可以拍照并在图库中显示图像的应用程序来学习 React Native。

我用来react-native-vision拍照并按照此答案react-native-fs中的建议访问临时文件,并将其用作uri<Image/>

但是,应该显示列表的视图</Image>显示空白

这是我的代码:

// saves photo on Array and closes the Camera View

const onPressButton = async () => {
    console.log(cameraRef.current);
    console.log(123);
    const photo = await cameraRef.current.takePhoto({
      flash: 'off',
      qualityPrioritization: 'speed',
    });

    console.log(photo);

    setPhotos([...photos, photo]);

    setShowCamera(false);
    return;
  };

   // how I'm trying to render the photos
      {photos && photos.length > 0 && (
    <View style={{width: '50%', height: '50%'}}>
    {photos.map((photo, index) => (
      <View key={index}>
        {console.log('file://' + DocumentDirectoryPath + …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-vision-camera

1
推荐指数
1
解决办法
2398
查看次数