首页 > 解决方案 > 无法在本机反应中共享图像

问题描述

我正在使用 react-native-share

import { Share } from 'react-native-share';   
let options = {
message:"hello",
url:uri
}
Share.open(options);

我得到这个错误未定义不是评估_reactnative.Share.open的对象

标签: react-nativereact-native-android

解决方案


我已将下载的图像转换为 base64 字符串,然后传入 Share.options

import  Share  from 'react-native-share';  //Don't put curly braces  
let options = {
message:"hello",
url:uri // pass base64 string like this "data:image/gif;base64,"+ base64 string 
}
Share.open(options);

这种方法对我有用


推荐阅读