我一直在努力解决这个问题。到目前为止我找不到任何答案/解决方案,我希望你们中的一个可以帮助我。
情况是这样的:我正在使用imgAreaSelect裁剪图像。但是用户可以改变宽高比。这可以通过输入宽度和高度(例如100:20)。
您可以在下面找到我的代码:
var ias = jQuery('#photo').imgAreaSelect({instance:true});
ias.setOptions({aspectRatio:'100:20'});
ias.update();
所以我在var ias
中有我的imgAreaSelect实例。但不知怎的,我无法通过SetOptions()
更改设置。
我得到的错误如下:
Uncaught TypeError: Object # has no method 'getOwnPropertyNames'
但奇怪的是,如果我做console.dir(ias)
我在控制台中完全看到了我的对象。其他一切都按预期工作。裁剪效果很好,我无法通过setOptions()
编辑我的选项。
我忘记了什么吗?
提前致谢!史蒂夫
答案 0 :(得分:0)
将setOptions
设为true
。请参阅示例代码:
var own = $('#crop_img').imgAreaSelect({x1: 0, y1: 0, x2: $('#crop_img').width(), y2: $('#crop_img').height(),
handles: true, instance:true,
aspectRatio:"{{ $javascript->ratio }}",
resizable:true,
persistent:true,
**setOptions:true**,
imageWidth:"{{ $javascript->width }}",
imageHeight:"{{ $javascript->height }}",