我是本机反应的新手,我想将项目中本地文件夹(如 Module/assets/ImageName.png)中的图像保存到文档目录中。我正在使用“react-native-fs”库。
代码如下:
componentWillMount() {
var RNFS = require('react-native-fs');
var path = RNFS.DocumentDirectoryPath + '/ImageName.png';
// write the file
RNFS.writeFile(path, './Module/assets/ImageName.png', 'utf8') // what to use inplace of utf8?
.then((success) => {
console.log(path);
})
.catch((err) => {
console.log(err.message);
});
}
请建议我应该如何进行?谢谢。