我用try catch来处理了accessSync不存在的情况,并且进行下面的其他逻辑,预览和开发者工具正常,但真机调试会报"error occurs:no such file or directory, access wxfile://usr/123.txt",但不走catch块而直接走try块下面的逻辑。
try {
fs.accessSync("xxx");
console.log("call 3");
return true;
} catch(e) {
console.error("call 1", e);
}
console.log("call 2");
如上,如果文件不存在的话也不会跑call 1和call 2,报错之后跑call 3去了。