html2canvas屏幕截图未显示拖动的子图像

时间:2018-07-28 09:22:24

标签: jquery html canvas drag-and-drop html2canvas

我创建了一个拖放图像到div,然后创建了画布和图像,但是新创建的图像仅显示图像的包装, 除了新图像的结果外,代码工作正常(在白色方块中,我需要显示图片) 我什至把图片送到了父节点树上

    $( "#droppable" ).droppable({
          containment: $('#droppable'),
          appendTo: $('#droppable'),

,例如:enter image description here

我的代码:

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>

0 个答案:

没有答案