From 9fa47008390fee3bfa28054542be5d0eaa2b461f Mon Sep 17 00:00:00 2001 From: Chef <38160059+Chef5@users.noreply.github.com> Date: Mon, 16 Oct 2023 09:36:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=8A=A8=E8=A3=81=E5=89=AA?= =?UTF-8?q?=E5=AE=BD=E9=AB=98=E5=BA=A6=E6=94=AF=E6=8C=81=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E7=99=BE=E5=88=86=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/vue-cropper.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/vue-cropper.vue b/src/vue-cropper.vue index 6341a73..a4086e9 100644 --- a/src/vue-cropper.vue +++ b/src/vue-cropper.vue @@ -1822,8 +1822,16 @@ export default { } // 截图框默认大小 // 如果为0 那么计算容器大小 默认为80% - var w = cw ? cw : parseFloat(this.autoCropWidth); - var h = ch ? ch : parseFloat(this.autoCropHeight); + var w = cw ? cw : ( + /^(\d{1,2}|100)%$/.test(this.autoCropWidth) + ? maxWidth * parseFloat(this.autoCropWidth) / 100 + : parseFloat(this.autoCropWidth) + ); + var h = ch ? ch : ( + /^(\d{1,2}|100)%$/.test(this.autoCropHeight) + ? maxHeight * parseFloat(this.autoCropHeight) / 100 + : parseFloat(this.autoCropHeight) + ); if (w === 0 || h === 0) { w = maxWidth * 0.8; h = maxHeight * 0.8;