问题:小程序创建目录,居然报权限错误如下
mkdirSync:fail permission denied, open ${wx.env.USER_DATA_PATH}/expResources
报错代码(这还是官方的示例写法,无语。。。)
let toPath = '${wx.env.USER_DATA_PATH}/expResources'
wx.getFileSystemManager().mkdirSync(toPath,true)
正确代码如下
let rp = wx.env.USER_DATA_PATH;
let toPath = rp + "/expResource";
wx.getFileSystemManager().mkdirSync(toPath,true)
网友评论