提交 5ac4c785 编写于 作者: X xiaoyucoding

feat(h5): previewImage 参数 current 支持传入索引值

上级 8690a6b6
...@@ -19,9 +19,11 @@ export const previewImage = { ...@@ -19,9 +19,11 @@ export const previewImage = {
} }
}, },
current: { current: {
type: String, type: [String, Number],
validator (value, params) { validator (value, params) {
params.type = value ? getRealPath(value) : '' // 假值都会被转换为数字 0 无需再做判定
const index = Number(value)
params.current = isNaN(index) ? getRealPath(value) : index
} }
} }
} }
...@@ -33,7 +33,7 @@ export default { ...@@ -33,7 +33,7 @@ export default {
} }
}, },
created () { 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 this.index = index < 0 ? 0 : index
}, },
methods: { methods: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册