我创建了一个拖放图像到div,然后创建了画布和图像,但是新创建的图像仅显示图像的包装, 除了新图像的结果外,代码工作正常(在白色方块中,我需要显示图片) 我什至把图片送到了父节点树上
$( "#droppable" ).droppable({
containment: $('#droppable'),
appendTo: $('#droppable'),
我的代码:
var takeScreenShot = function() {
html2canvas(document.getElementById("container"), {
onrendered: function (canvas) {
var tempcanvas=document.createElement('canvas');
var context=tempcanvas.getContext('2d');
context.drawImage(canvas,0,0);
var link=document.createElement("a");
link.href=tempcanvas.toDataURL('image/jpg');
link.download = 'screenshot.jpg';
link.click();
}
});
}
和html:
<div ng-repeat="user in users"
href="#/{{user.id}}"
class="item item-thumbnail-left">
<img id="" ng-src="{{ user.picture }}" class="draggably resizably ">
</div>
<img id="droppable" src="img/background.jpeg">
</div>