我搜索了很多但没有找到从剪贴板获取base64编码数据.我可以捕获粘贴事件,然后将事件分配给变量
clipBoard = e.clipboardData ? e.clipboardData : window.clipboardData;
Run Code Online (Sandbox Code Playgroud)
在铬; 我可以得到已粘贴的打印屏幕,就像这样
if (clipBoard.types[0] == "Files") {
var blob = clipBoard.items[0].getAsFile();
var reader = new FileReader();
reader.onload = function(event){
console.log(event.target.result);
}; // data url!
reader.readAsDataURL(blob);
}
Run Code Online (Sandbox Code Playgroud)
但是在11中,clipBoard变量没有"items"或"types".我将上传该图像服务器,但我没有得到base64编码数据.