我试图在点击下载按钮时打开保存对话框。它适用于 Chrome 和 Edge。但我的首要任务是 FireFox。它在 FireFox 中不起作用。
我正在使用 文件系统访问 API 打开保存对话框
当我在 FireFox 中运行时得到 Uncaught (in promise) TypeError: window.showSaveFilePicker is not a function error.
请帮我解决 FireFox 浏览器中的这个问题
提前致谢
document.querySelector(".btnTemp").onclick = async () => {
const options = {
types: [
{
description: "Test files",
accept: {
"text/plain": [".txt"],
},
},
],
};
const handle = await window.showSaveFilePicker(options);
const writable = await handle.createWritable();
await writable.write("Hello World");
await writable.close();
return handle;
};
请看这里:https://developer.mozilla.org/en-US/docs/Web/API/Window/showSaveFilePicker
showSaveFilePicker
是实验性的,目前仅支持 chrome、opera 和 edge。