el-image组件大图预览定位当前图片

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <!-- import CSS -->
  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="app">
  <div class="block" v-for="(url, index) in urls">
    <el-image
      style="width: 100px; height: 100px"
      :src="url"
      :preview-src-list="getSrcList(index)"></el-image>
  </div>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
new Vue({
  el: '#app',
  data: {
    urls: [
      'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
      'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
      'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg'
    ]
  },
  methods:{
    getSrcList(index){
      return this.urls.slice(index).concat(this.urls.slice(0,index))
    }
  }
})
</script>
</html>

 

posted @ 2020-04-21 17:30  lezuw  阅读(3063)  评论(2编辑  收藏  举报