亲宝软件园·资讯

展开

vue js图片切换 vue+js点击箭头实现图片切换

anshengsuiyeu 人气:0
想了解vue+js点击箭头实现图片切换的相关内容吗,anshengsuiyeu在本文为您仔细讲解vue js图片切换的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:vue,js,图片切换,下面大家一起来学习吧。

前端需求是 返回的图片数据能够点击箭头切换

代码如下

 <div class="pubuItemsBox">
        <!-- 修改部分5.23晚 -->
        <template v-for="(orderEvent, index) in orderEventList" >
          <div :class="{'pubuItem':true, 'noMag':(index+1)%3 == 0}">
            <div class="imgDivs">
              <template v-if="orderEvent.eventFocuspic.split(',').length > 1">
                <ins class="left"  @click='change(index,"prev")'></ins>
                <ins class="right"  @click='change(index,"next")'></ins>
              </template>
              <ul class="ulZpImg">
                <template v-for="(imgUrl,imgUrlIndex) in orderEvent.eventFocuspic.split(',')" >
                  <li v-show='imgUrlIndex===orderEvent.mark'><img :src="getImageUrl(showImg(imgUrl))"></li>
                </template>
              </ul>
            </div>
            <div class="txtBox">
              <span>{{orderEvent.brandName}}</span><ins>档期:{{orderEvent.beginDate}}至{{orderEvent.endDate}}</ins>
            </div>
            <p style="-webkit-box-orient: vertical;">{{orderEvent.eventDesc}}</p>
          </div>
        </template>
      </div>
 
 
<script>
change(i, type){
        var obj = this.orderEventList[i];
        var imgLength =obj.eventFocuspic.split(',').length;
        if (type === "prev") {
          if (obj.mark == 0) {
            obj.mark = imgLength - 1
            return
          }
          obj.mark--;
        }
        if (type === "next") {
          if (obj.mark == imgLength - 1) {
            obj.mark = 0
            return
          }
          console.log(obj.mark)
          obj.mark++;
        }
      }
</script>

加载全部内容

相关教程
猜你喜欢
用户评论