如何在 React Native 中获取 base64 下的图像?

问题描述

我使用这个库https://github.com/itinance/react-native-fs

我在 IOS 上测试过。

这是我的代码

import Room1 from 'assets/image/livingRoom.jpg';

    RNFS.readFile(
      `file://${RNFS.MainBundlePath}/src/assets/image/livingRoom.jpg`,'base64'
    ).then((res) => {
      console.log(res);
    });

我得到了错误

Error: ENOENT: no such file or directory,open 'file///private/var/containers/Bundle/Application/472B157F-14DB-443A-BBE0-0C21A2F67DFB/ferqo.app/src/assets/image/livingRoom.jpg'

我不知道为什么路径是错误的。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)