ReadFromFile:function (params) {
let fsm = wx.getFileSystemManager();
console.log(wx.env.USER_DATA_PATH),
wx.saveFile({
tempFilePath: wx.env.USER_DATA_PATH + "/Crsmini.txt",
success(res) {
fsm.readFile({
filePath:res.savedFilePath,
encoding: 'utf8',
success:function(res){
console.log(res.data) }
})
},
fail: res => {
console.info(res)}
})
- 这里是读取保存的文本问题,提示错误 {errMsg: "saveFile:fail tempFilePath file not exist"}
- errMsg: "saveFile:fail tempFilePath file not exist"
- __proto__: Object
你好,麻烦具体描述问题流程,提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html
var that=this;
var crsfilepath =wx.env.USER_DATA_PATH + "/tmp.txt"
let fsm = wx.getFileSystemManager();
fsm.writeFile({
filePath: crsfilepath,
data: " UserID:" + that.data.UserID + "\n" +
" UserPass:" + that.data.UserPass + "\n" +
" UserWeb" + that.data.UserWeb + "\n",
encoding: 'utf8',
success: res => {
console.info(res) ;
console.log("成功");
},
fail: res => {
console.info(res);
}
});
wx.getSavedFileList({
success (res) {
if (res.fileList.length > 0){
console.log(res.fileList[0].filePath),
wx.removeSavedFile({
filePath: res.fileList[0].filePath,
complete (res) {
console.log("文件长度" + res)
}
})
}
else
{ console.log(res)}
},
fail(res)
{
console.log(res);
}
})
},
{errMsg: "writeFile:ok"}
login.js:163 成功
login.js:181 {errMsg: "getSavedFileList:ok", fileList: Array(0)}
保存提示成功了,但是用 getSavedFileList结果确实空