diff --git a/src/core/helpers/protocol/media/preview-image.js b/src/core/helpers/protocol/media/preview-image.js index 8981f5665aa47b998bfedbb70205983775ad6dab..43e87e18372a97de992d80d6cff15b65abf4d8dc 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 8eab5d3963083eef2204f04873a149cbb5032165..52cb2a21edfa8c14d14415ff0352428e228339d0 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: {