小编Oli*_*via的帖子

本地函数myFunction与本地myFunction = function()有什么区别?

我知道这个问题看起来很简单,但我想知道在Lua中创建函数的两种方法之间的区别:

local myFunction = function()
    --code code code
end
Run Code Online (Sandbox Code Playgroud)

或者这样做

local function myFunction()
    --code code code
end
Run Code Online (Sandbox Code Playgroud)

lua scope

6
推荐指数
1
解决办法
1291
查看次数

使用 react-native-fs 将文件从 tmp 移动到文档

我正在尝试使用react-native-fsreact-native-document picker将从文档选择器中选择的文件移动到文档目录。

但是,我收到以下错误:

Error: “file name.mp3” couldn’t be moved to “Documents” because either the former doesn't exist, or the folder containing the latter doesn't exist.
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

仅供参考,我正在使用iOS。

openDocumentPicker() {
  DocumentPicker.show({
    filetype: ['public.audio'],
  },(error,url) => {
    console.log(url);
    this.saveAudio(url);
  });

}

saveAudio(url) {

  var destPath = RNFS.DocumentDirectoryPath + '/' + 'name';

  RNFS.moveFile(url, destPath)
    .then((success) => {
      console.log('file moved!');
    })
    .catch((err) => {
      console.log("Error: " + err.message);
    });
}
Run Code Online (Sandbox Code Playgroud)

react-native react-native-fs react-native-ios

6
推荐指数
1
解决办法
6729
查看次数