【问题标题】:not able to crop image无法裁剪图像
【发布时间】:2015-04-21 10:50:34
【问题描述】:

我创建了一个使用 cropper.js 来裁剪图像的应用程序,该应用程序正在运行并且图像正在生成,但我无法裁剪图像。我的代码如下所示

谁能告诉我一些解决方法

Plunker

html

<div class="container">
  <img src="http://fengyuanchen.github.io/cropper/img/picture.jpg" />
</div>

脚本

$('.container > img').cropper({ 
  aspectRatio: 16 / 9,
  crop: function(data) {
    // Output the result data for cropping image.
  }
});

【问题讨论】:

  • 你不需要设置aspectRatio吗?
  • 是强制性的,我们如何设置它
  • 根据您链接到的 github 存储库中给出的示例
  • @atmd 好的,我已经更新了,添加了纵横比,仍然无法正常工作

标签: jquery html image crop


【解决方案1】:

您需要在文档就绪块中触发您的裁剪器代码,如下所示:

$(function (){
    $('.container > img').cropper({ 
       aspectRatio: 16 / 9,
       crop: function(data) {
       // Output the result data for cropping image.
       }
    });
});

在图像在 dom 中呈现之前运行裁剪代码的位置

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-29
    • 2013-07-28
    • 2020-02-02
    • 2016-11-22
    • 2020-10-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多