【问题标题】:How to share multiple files with react-native-share如何使用 react-native-share 共享多个文件
【发布时间】:2020-10-30 13:24:30
【问题描述】:

我正在处理我的项目,我需要实现一种通过 react-native-share 或任何其他模块发送多个文件的方法

<TouchableOpacity
  onPress={() => {
    const pathUrl = "file://"+this.state.pdfInfo[0].path
    Share.open({
      url: [pathUrl, pathUrl]
    })
      .then((res) => {
        console.log(res);
    })
      .catch((err) => {
        console.log(err);
    });
  }}
  style={{marginRight:20}}
>
  <Icon name="md-share-social" size={25} color="black"/>
</TouchableOpacity>

当用户按下此图标时,它应该与数组共享多个文件。但是,既然 react-native-share 需要字符串,那么我们怎么去呢???

还有其他方法吗??

【问题讨论】:

标签: react-native react-redux shared-libraries react-native-android file-sharing


【解决方案1】:

只需将url 替换为urls

<TouchableOpacity
  onPress={() => {
    const pathUrl = "file://"+this.state.pdfInfo[0].path
    Share.open({
      urls: [pathUrl, pathUrl]
    })
      .then((res) => {
        console.log(res);
    })
      .catch((err) => {
        console.log(err);
    });
  }}
  style={{marginRight:20}}
>
  <Icon name="md-share-social" size={25} color="black"/>
</TouchableOpacity>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-22
    • 2018-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多