[英]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.