<div>
<el-image
ref="imageEnlargeRef"
style="width: 1px; height: 1px; position: absolute; opacity: 0"
:src="url"
:preview-src-list="getPreviewImages(3)"
></el-image>
</div>
getPreviewImages(index) {
var imgList = [...this.srcList]
console.log(index, 'imgList')
if (index === 0) return imgList
var start = imgList.splice(index)
var remain = imgList.splice(0, index)
console.log('start.concat(remain)', index)
return start.concat(remain)
}
elment-ui el-image 设置initial-index失效 导致无法改变图片预览顺序
最新推荐文章于 2025-10-15 19:06:21 发布
该段代码展示了在Vue中使用el-image组件实现图片预览的功能。通过ref和getPreviewImages方法处理预览源列表,根据传入的index动态调整图片顺序。getPreviewImages函数利用splice操作数组,将当前索引的图片移到预览列表首位。
2287






