Commit e2babef779af5758ff614f57b5d731567fb43561

Authored by zhiyangdu
1 parent e2d99d7f

图片预览

src/components/palaceGrid/palaceGrid.less
... ... @@ -44,4 +44,14 @@
44 44 }
45 45 }
46 46 }
  47 + .van-image-preview__index{
  48 + font-size: 30px;
  49 + }
  50 + .van-swipe__indicators{
  51 + bottom: 100px;
  52 + .van-swipe__indicator{
  53 + width: 16px;
  54 + height: 16px;
  55 + }
  56 + }
47 57 }
... ...
src/components/palaceGrid/palaceGrid.vue
... ... @@ -2,7 +2,7 @@
2 2 <div class="palace-grid-box" v-if="grids && grids.list && grids.list.length">
3 3 <div class="box">
4 4 <div class="img-box" >
5   - <div :class="['item',grids.list.length==1?'one':(grids.list.length==2 || grids.list.length==4? 'two':'three')]" v-for="(item, index) in grids.list" :key="index" @click="jump(item)">
  5 + <div @click.stop="imagePreview(index)" :class="['item',grids.list.length==1?'one':(grids.list.length==2 || grids.list.length==4? 'two':'three')]" v-for="(item, index) in grids.list" :key="index" @click="jump(item)">
6 6 <van-image
7 7 v-if="index<9"
8 8 class="img"
... ... @@ -13,6 +13,9 @@
13 13 </div>
14 14 </div>
15 15 </div>
  16 + <van-image-preview v-model="show" :swipeDuration="20000" :start-position="index" :show-indicators="true" :images="grids.list" @change="onChange">
  17 + <template v-slot:index>第{{ index }}页</template>
  18 + </van-image-preview>
16 19 </div>
17 20 </template>
18 21  
... ... @@ -20,18 +23,37 @@
20 23 export default {
21 24 name: "palaceGrid",
22 25 data: function () {
23   - return {
  26 + return {show: false,
  27 + index: 0,
  28 + images: [
  29 + 'https://img.yzcdn.cn/1.jpg',
  30 + 'https://img.yzcdn.cn/2.jpg'
  31 + ]
  32 +
24 33 }
25 34 },
26 35 props: ["grids"],
27 36 methods: {
28   -
29 37 /**
30 38 * 点击跳转事件绑定
31 39 */
32 40 jump(item) {
33 41 this.$emit("jump", item);
34   - }
  42 + },
  43 + /**
  44 + * 图片预览
  45 + */
  46 + imagePreview(index){
  47 + this.show = true;
  48 + this.index = index;
  49 +
  50 + },
  51 + /**
  52 + * 点击轮播图变大
  53 + */
  54 + onChange(index) {
  55 + this.index = index;
  56 + }
35 57 }
36 58 }
37 59 </script>
... ...