From 5714e649e0e4daa5316d29d0b430daf9654bc76a Mon Sep 17 00:00:00 2001 From: qiang Date: Tue, 25 Jun 2019 13:07:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3H5=E7=AB=AFuni.preview?= =?UTF-8?q?Image=E6=8E=A5=E5=8F=A3current=E5=8F=82=E6=95=B0=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E6=97=B6=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/helpers/protocol/media/preview-image.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/helpers/protocol/media/preview-image.js b/src/core/helpers/protocol/media/preview-image.js index 43e87e183..cd49f0581 100644 --- a/src/core/helpers/protocol/media/preview-image.js +++ b/src/core/helpers/protocol/media/preview-image.js @@ -21,9 +21,12 @@ export const previewImage = { current: { type: [String, Number], validator (value, params) { - // 假值都会被转换为数字 0 无需再做判定 - const index = Number(value) - params.current = isNaN(index) ? getRealPath(value) : index - } + if (typeof value === 'number') { + params.current = value > 0 && value < params.urls.length ? value : 0 + } else if (typeof value === 'string' && value) { + params.current = getRealPath(value) + } + }, + default: 0 } } -- GitLab