我在anki 中引入了如下库:
https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js
使用如下代码将元素转化为图像,并且顺利的将图像插入到了文档中,我想问,如何将生成的图像复制到剪切板中。
$(document).on('click', '#'+sanitizedTitle+index+'_hoverDiv'+' .biaozhuXuanGua', function(e) {
var targetElement = $('#' + sanitizedTitle + index + '_hoverDiv');
html2canvas(targetElement.get(0),{
backgroundColor: null,
imageTimeout:0,
scale: window.devicePixelRatio
}).then(canvas => {
document.body.appendChild(canvas);
}).catch(error => {
alert('Error generating canvas:'+error);
});
});