小程序轮播中嵌入视频-关于swiper、video组件与block标签

时间:2022-07-23
本文章向大家介绍小程序轮播中嵌入视频-关于swiper、video组件与block标签,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

一、官方文档

about video Component about swiper Component

二、注意事项

注意事项

三、卡片式轮播效果图

效果图

四、示例代码

blcok标签不做渲染

<view id='banner' style="{{banner == ''?'display:none':''}}">
  <!-- <swiper indicator-dots="{{true}}" indicator-color="#ffffff" autoplay="true" circular="true"  >
    <block wx:for="{{banner}}" wx:key="*this" >
      <swiper-item>
        <image src='{{item}}'mode="aspectFill" style="width:100%;height:100%;" mode="widthFix"  />
      </swiper-item> 
    </block>
  </swiper> -->
  <swiper class="card-swiper {{DotStyle?'square-dot':'round-dot'}}" indicator-dots="true" circular="true" autoplay="true" interval="5000" duration="500" bindchange="cardSwiper" indicator-color="#8799a3" indicator-active-color="#0081ff">
    <swiper-item>
      <block>
        <!-- <view class="swiper-item"> -->
          <video
            autoplay 
            loop
            class="swiper-item"
            show-play-btn="{{true}}"
            controls="{{true}}"
            objectFit="cover" 
            loop='{{false}}'
            show-mute-btn='{{true}}'
            vslide-gesture-in-fullscreen='{{true}}'
            src="https://xxxxx.mp4" 
          ></video>
        <!-- </view> -->
      </block>
      <!-- autoplay 
          loop="{{false}}"
          bindplay="handlePlayVideo"
          bindpause = 'handleStopVideo' -->
       <!-- show-play-btn="{{true}}" controls="{{true}}" objectFit="cover" loop='{{false}}' show-mute-btn='{{true}}' vslide-gesture-in-fullscreen='{{true}}'  -->
    </swiper-item>
    <swiper-item wx:for="{{banner}}" wx:key="*this" class="{{cardCur==index?'cur':''}}">
      <view class="swiper-item">
        <image src="{{item}}" mode="aspectFill"></image>
        <!-- <video src="{{item.video}}" autoplay loop muted show-play-btn="{{false}}" controls="{{false}}" objectFit="cover" wx:if="{{item.type=='video'}}"></video> -->
      </view>
    </swiper-item>
  </swiper>
</view>