我想按照示例来使用这个新的 API 。基本设置没有问题,尽管当我尝试使用createSyncAccessHandle()方法时它立即失败。将其更改为会createAccessHandle()产生相同的结果。我有错误TypeError: fileHandle.createSyncAccessHandle is not a function。这是代码:
const root = await navigator.storage.getDirectory();
const fileHandle = await root.getFileHandle('Untitled.txt', { create: true });
const accessHandle = await fileHandle.createSyncAccessHandle();
Run Code Online (Sandbox Code Playgroud)
有没有办法可以在 chrome 扩展中使用这个 OPFS 功能?它在服务工作者内部以及弹出脚本中都会失败(例如)。
注意:OPFS 的其他功能(如createWritable()/getFile())运行良好。