收藏
回答

mac版开发工具,无法读取本地文件,提示no such file,该如何解决?

onLoad: function () {


    wx.getFileSystemManager().copyFile({ //先把文件复制到可操作的文件夹
      srcPath: '../data.json', //源文件
      destPath: wx.env.USER_DATA_PATH + '/data.json', //可操作的4文件夹路径
      success: res => {
        console.log(res) //复制成功返回res信息
      },
      fail: console.error //复制失败返回error
    }),



    wx.getFileSystemManager().readFile({ //读取文件
      filePath:  'data.json',
      encoding: 'utf-8',
      encoding: 'utf-8',
      success: res => {
        console.log(res.data)
      },
      fail: console.error
    })
  }
}
文件名试过  data.json 或者  ..\data.json 都不行。

回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容
问题标签