【问题标题】:croppie - outWHeight is not definedcroppie - outWHeight 未定义
【发布时间】:2018-04-14 16:37:46
【问题描述】:

我正在使用带有引导模式的 Croppie,例如 this,但我在浏览器控制台中收到以下错误,这意味着当我单击“裁剪”按钮时,错误如下: ReferenceError:outWHeight 未定义 这是我的 Js 代码(您可以在 CodePen 链接中找到完整的代码):

var $uploadCrop,
        tempFilename,
        rawImg,
        imageId;
        function readFile(input) {
            if (input.files && input.files[0]) {
              var reader = new FileReader();
                reader.onload = function (e) {
                    $('.upload-demo').addClass('ready');
                    $('#cropImagePop').modal('show');
                    rawImg = e.target.result;
                }
                reader.readAsDataURL(input.files[0]);
            }
            else {
                swal("Sorry - you're browser doesn't support the FileReader API");
            }
        }

        $uploadCrop = $('#upload-demo').croppie({
            viewport: {
                width: 250,
                height: 250,
            },
            enforceBoundary: false,
            enableExif: true
        });
        $('#cropImagePop').on('shown.bs.modal', function(){
            // alert('Shown pop');
            $uploadCrop.croppie('bind', {
                url: rawImg
            }).then(function(){
                console.log('jQuery bind complete');
            });
        });

        $('.item-img').on('change', function () { imageId = $(this).data('id'); tempFilename = $(this).val();
                                                                                         $('#cancelCropBtn').data('id', imageId); readFile(this); });
        $('#cropImageBtn').on('click', function (ev) {
            $uploadCrop.croppie('result', {
                type: 'base64',
                format: 'jpeg',
                size: {width: 1000, height: 1000}
            }).then(function (resp) {
                $('#item-img-output').attr('src', resp);
                $('#cropImagePop').modal('hide');
            });
        });

【问题讨论】:

  • 我无法重现错误
  • @CarstenLøvboAndersen 错误不在 codepen 中。当我在我的网站上使用代码时,出现错误 ReferenceError: outWHeight is not defined
  • 我没有对代码做任何改动!
  • 它必须与您拥有的其他代码有关,因为您没有在 sn-p 中使用outWHeight
  • @CarstenLøvboAndersen 我测试了错误。我删除了其他库,但失败了。

标签: jquery croppie


【解决方案1】:

您的代码没有问题,并更新项目中使用的所有库。另外,使用 Croppie 的如下库,也就是替换它:

https://foliotek.github.io/Croppie/croppie.js

【讨论】:

  • 谢谢,你的方法解决了我的问题。出了什么问题?
  • @HosseinKaraji 您的旧作物库中有一个错误。问题已通过更新新库解决,请始终使用最新库进行更新。
猜你喜欢
  • 2018-09-01
  • 2018-10-19
  • 2023-02-12
  • 2010-10-21
  • 2016-04-28
  • 2017-05-28
  • 2018-09-08
  • 1970-01-01
相关资源
最近更新 更多