<el-dialog :visible.sync="dialogVisible" class="picture">
<el-carousel height="500px" :initial-index="0" :autoplay = "false" @change="sildeImg" ref="carousel">
<el-carousel-item v-for="(item,index) in pictureList" :key="index" >
<img width="100%" :src="item.url" alt="" height="500px">
</el-carousel-item>
</el-carousel>
</el-dialog>
picturePreview: function(file) {
this.dialogImageUrl = file.url;
this.dialogVisible = true;
var currentIndex;
for (let i = 0; i <totalIndex ; i++) {
if(file.url == this.pictureList[i].url){
currentIndex = i ;
}
}
if(this.$refs['carousel']){this.$refs['carousel'].activeIndex = currentIndex;}
},
通过修改走马灯组件内部的activeIndex ,实现用户点击哪张图片就显示哪张图片。
|