uni视频图片轮播封装

1.view代码

<view class="" v-if="swiperList.length>0">
            <!-- <zg-swiper :list="swiperList"></zg-swiper> -->
            <swiper class="swiper" circular indicator-color="#ffffff" indicator-active-color="#00aa7f" :indicator-dots="true" :autoplay="swiperAutoplay" :interval="3000"
                :duration="1500" @change='swiperChange'>
                <swiper-item v-for="(item,index) in swiperList" :index="index" :key="index">
                    <video :id="`video${index}`" style="width: 100%;height:100%" v-if="item.type === 'video'"
                        :videoAutoplay="videoAutoPlay" :enable-progress-gesture="false" :src="item.src"
                        @play="handleVideoPlay" @pause="handleVideoPause" @ended="handleVideoEnd"></video>
                    <image  style="width: 100%;" v-if="item.type === 'image'" :src="item.src"></image>
                </swiper-item>
            </swiper>
        </view>

2.data数据

return {

                videoAutoPlay: false,
                videoIndex: 0,
                swiperAutoplay: true,
                swiperList: [],

}

3.事件处理

            //banner事件
            swiperChange(detail) {
                //切换时要把视频暂停
                uni.createVideoContext("video" + (this.videoIndex)).pause()
                this.videoIndex = detail.detail.current
            },
            handleVideoPlay() {
                this.swiperAutoplay = false
                this.videoAutoPlay = true;
            },
            handleVideoPause() {
                this.swiperAutoplay = true
            },
            handleVideoEnd() {
                this.swiperAutoplay = true;
            },

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
uni-app是一个使用Vue.js开发跨平台应用的框架。它支持在多个平台上构建应用程序,其中包括小程序。在uni-app中实现轮图功能可以使用官方提供的swiper组件,该组件在uniapp官网的文档中有详细介绍,并提供了相关的API供参考。在使用swiper组件之前,需要先了解其基本的用法和属性设置。如果需要更加个性化的轮图效果,可以根据需求进行自定义实现。另外,基于Vue实现的管理后台也可以使用uni-app进行配置和开发,实现后台系统中的轮图功能。总之,uni-app提供了方便快捷的轮图组件和开发工具,可以帮助开发者轻松实现轮图功能。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [【uniapp小程序开发】—— 组件封装之【自定义轮图】](https://blog.csdn.net/qq_49002903/article/details/126809121)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *2* [vue+uni-app轮图.zip](https://download.csdn.net/download/qq_15908191/16206422)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

浮生若梦l

你的鼓励实我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值