[英]Javascript: How to save ArrayBuffer when the script is rendering from server side?
脚本文件是从服务器端呈现的,当我使用下面的代码从脚本下载数据时
const blob = new Blob([data]);
var a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.download = "1.mp4";
a.click();
URL.revokeObjectURL(a.href);
它表明document is not defined
。 有没有办法解决这个问题?
我通过将代码分成两部分解决了这个问题。
const blob = new Blob([data]);
console.log(URL.createObjectURL(blob));
var a = document.createElement("a");
a.href = 'blob:{paste the url address}';
a.download = "1.mp4";
a.click();
URL.revokeObjectURL(a.href);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.