我在我的控制台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
}
}