From 5ac4c7856adefbc5cfbb66f3d11ef84f868a28cc Mon Sep 17 00:00:00 2001 From: xiaoyucoding Date: Tue, 7 May 2019 16:13:07 +0800 Subject: [PATCH] =?UTF-8?q?feat(h5):=20previewImage=20=E5=8F=82=E6=95=B0?= =?UTF-8?q?=20current=20=E6=94=AF=E6=8C=81=E4=BC=A0=E5=85=A5=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/helpers/protocol/media/preview-image.js | 6 ++++-- .../h5/components/system-routes/preview-image/index.vue | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/helpers/protocol/media/preview-image.js b/src/core/helpers/protocol/media/preview-image.js index 8981f5665..43e87e183 100644 --- a/src/core/helpers/protocol/media/preview-image.js +++ b/src/core/helpers/protocol/media/preview-image.js @@ -19,9 +19,11 @@ export const previewImage = { } }, current: { - type: String, + type: [String, Number], validator (value, params) { - params.type = value ? getRealPath(value) : '' + // 假值都会被转换为数字 0 无需再做判定 + const index = Number(value) + params.current = isNaN(index) ? getRealPath(value) : index } } } diff --git a/src/platforms/h5/components/system-routes/preview-image/index.vue b/src/platforms/h5/components/system-routes/preview-image/index.vue index 8eab5d396..52cb2a21e 100644 --- a/src/platforms/h5/components/system-routes/preview-image/index.vue +++ b/src/platforms/h5/components/system-routes/preview-image/index.vue @@ -33,7 +33,7 @@ export default { } }, created () { - var index = this.urls.indexOf(this.current) + const index = typeof this.current === 'number' ? this.current : this.urls.indexOf(this.current) this.index = index < 0 ? 0 : index }, methods: { -- GitLab