【发布时间】:2021-11-20 06:31:52
【问题描述】:
我试图将画布 blob 存储到导航器剪贴板中
graphicDiv.addEventListener(
'click',
(event) => {
const canvas = <HTMLCanvasElement> document.getElementById('canvas');
canvas.toBlob((blob) => {
if (blob) {
let data = [new ClipboardItem({ [blob.type]: blob })];
navigator.clipboard.write(data).then(
function () {},
function (err) {}
);
}
});
},
false
);
似乎出了点问题,因为 TS 给了我如下错误
Argument of type '{ [x: string]: Blob; }' is not assignable to parameter of type 'Record<string, ClipboardItemData>'.
'string' index signatures are incompatible.
Type 'Blob' is missing the following properties from type 'Promise<ClipboardItemDataType>
error TS2339: Property 'write' does not exist on type 'Clipboard'.
102 let data = [new ClipboardItem({ [blob.type]: blob })];
~~~~~
有没有高手知道如何将 canvas chartjs 图表存储到剪贴板中?
【问题讨论】:
标签: javascript html typescript chart.js angular12