writeFileSync
发布于 6 年前 作者 yang19 7894 次浏览 来自 问答

wx.getSavedFileList({

success:function(res){

if(res.fileList.length==0){

let fs = wx.getFileSystemManager();

fs.writeFileSync(`${wx.env.USER_DATA_PATH}/hello.txt`, ‘hello, world’, ‘utf8’)

}

}

})

为什么没有创建文件

2 回复

https://developers.weixin.qq.com/miniprogram/dev/framework/ability/file-system.html 文件是有几种类型的,getSavedFileList 操作的是本地缓存文件,writeFileSync 操作的是本地用户文件,两者间不存在关系。

请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

回到顶部