收藏
回答

FileSystemManager无法读取代码包内文件,提示file not found,什么原因?

我在代码包内放了一个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 个回答

  • Mr.Zhao
    Mr.Zhao
    2021-08-08

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

    2021-08-08
    有用 1
    回复
登录 后发表内容