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 都不行。
https://developers.weixin.qq.com/s/mmcVndmY77kO
你好,哪个版本的开发者工具?请提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。