Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 如何在react native中下载文件?_React Native_Expo - Fatal编程技术网

React native 如何在react native中下载文件?

React native 如何在react native中下载文件?,react-native,expo,React Native,Expo,我在控制台中运行了这个命令npm install react native fs--save 然后在我的onclick函数中使用此代码 _download = (downloadpath) => { // console.log(introduction); var RNFS = require('react-native-fs'); try { RNFS.downloadFile({ fromUrl: downloadpath,

我在控制台中运行了这个命令
npm install react native fs--save
然后在我的onclick函数中使用此代码

 _download =  (downloadpath) => {
  // console.log(introduction);
var RNFS = require('react-native-fs');

   try {

    RNFS.downloadFile({
        fromUrl: downloadpath,
        toFile: `${RNFS.DocumentDirectoryPath}/test.zip`,
      }).promise.then((r) => {
        this.setState({ isDone: true })
      });

} catch (error) {

   console.log(error);
  // Error saving data
}


  }
但是它给了这个

很遗憾,RNFS与expo不兼容,因为它包装了本机库。你通常可以在家里查看