jQuery cropit导出方法仅返回'data:,'字符串

omi*_*ahi 5 html jquery crop

我的cropit的html代码:

<div id="image-cropper" style="direction: ltr">
    <div class="row margin-top-25">
        <div class="col-md-8 col-md-offset-2">
            <div class="cropit-image-preview-container">
                <div class="cropit-image-preview"></div>
            </div>
        </div>
    </div>
    <div class="row margin-top-15">
        <div class="col-md-4 col-md-offset-4">
            <input type="range" class="cropit-image-zoom-input" />
        </div>
    </div>
    <div class="row margin-top-15">
        <div class="col-md-4 col-md-offset-4">
            <input type="file" style="display: none" class="cropit-image-input" />
            <div class="R_butt_blue choose_pic text-center">?????? ?????</div>
        </div>
    </div>

</div>
Run Code Online (Sandbox Code Playgroud)

和我的cropit javascript代码:

$('.choose_pic').click(function(){
     $('.cropit-image-input').click();
});

var z = $('#image-cropper').cropit({
    exportZoom: 1,
    imageBackground: true,
    imageBackgroundBorderWidth: 15 // Width of background border
});
$('.send_image').click(function(){
    var h = z.cropit('export');
    $('#photo_show img').attr({ src: h });
});
Run Code Online (Sandbox Code Playgroud)

我想通过使用cropit jquery插件裁剪图像,我在网上阅读完整文档和多个示例,但是只返回包含data:, 我不知道什么是错误的字符串?

Rez*_*-S4 4

您应该定义.cropit-image-previewcss 类来设置裁剪图像的宽度和高度。

.cropit-image-preview {
  /* You can specify preview size in CSS */
  width: 100px;
  height: 100px;
}
Run Code Online (Sandbox Code Playgroud)

并且还可以像这样使用选择器:

var z = $('#image-cropper');
z.cropit({
    exportZoom: 1,
    imageBackground: true,
    imageBackgroundBorderWidth: 15 // Width of background border
});
Run Code Online (Sandbox Code Playgroud)

试试这个: http: //jsfiddle.net/grzveb09/