From 4a3fd118be6a1e03da01b17e71dd81d36f9d899d Mon Sep 17 00:00:00 2001 From: KINGXINL <45926545+KINGXINL@users.noreply.github.com> Date: Tue, 2 May 2023 16:38:44 +0800 Subject: [PATCH] Update vue-cropper.vue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复在初始化的情况下 图片宽高超出时的计算 当不固定宽高时 无需计算相对应的宽高 --- src/vue-cropper.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/vue-cropper.vue b/src/vue-cropper.vue index 79578fc..dc6f87b 100644 --- a/src/vue-cropper.vue +++ b/src/vue-cropper.vue @@ -1828,12 +1828,16 @@ export default { if (w > axis.x2 - axis.x1) { // 宽度超标 w = axis.x2 - axis.x1; - h = (w / this.fixedNumber[0]) * this.fixedNumber[1]; + if (this.fixed) { + h = (w / this.fixedNumber[0]) * this.fixedNumber[1]; + } } if (h > axis.y2 - axis.y1) { // 高度超标 h = axis.y2 - axis.y1; - w = (h / this.fixedNumber[1]) * this.fixedNumber[0]; + if (this.fixed) { + w = (h / this.fixedNumber[1]) * this.fixedNumber[0]; + } } } // 判断是否大于容器