md
- showOpenFilePicker() 获取文件句柄
- showSaveFilePicker() 保存文件句柄
- getFile() //获取文件内容
let study = async () => { let fileHandle; [fileHandle] = await window.showOpenFilePicker() const fileBlob = await fileHandle.getFile() console.log(await fileBlob.text())
// createWritable()创建一个可写流对象WritableStream const writable = await fileHandle.createWritable(); // 通过管道将数据传输到文件,write支持流的 await writable.write('contents'); // 管道使用完毕后需要关闭 await writable.close();}let study = async () => { const options = { types: [ { description: "Hello File Access Api", accept: { 'text/plain': ['.txt'], }, }, ], };
return await window.showSaveFilePicker(options);
}