FileSystemManager无法读取代码包内文件,提示file not found,什么原因?
发布于 4 年前 作者 leidu 9831 次浏览 来自 问答

我在代码包内放了一个gltf文件,并改成了.txt后缀,在代码里使用以下方法读取文件内容:

const fs = wx.getFileSystemManager();
let content=fs.readFileSync('/libs/models/free_porsche_911_carrera_4s/scene.gltf.txt');
console.log(content);

但是开发工具调试报以下错误:

[读取文件/文件夹警告] 无法读取 /libs/models/free_porsche_911_carrera_4s/scene.gltf.txt 
文件或文件夹不在白名单中, 上传时会被忽略, 在真机上可能无法读取
Error: readFileSync:fail /libs/models/free_porsche_911_carrera_4s/scene.gltf.txt not found
1 回复

原因就是不支持代码包内文件

回到顶部