当前位置: 首页 > news >正文

vue-awesome-swiper 问题

1.无法使用ref

		<Swiper loop ref="swiperRef" class="swiper animate__animated animate__fadeIn" :modules="modules":slides-per-view="5" :centered-slides="true" :space-between="0" :grab-cursor="true"@swiper="onSwiperInit" @slide-change="changeSwiper" @click="clickSwiperItem"><SwiperSlide v-for="(n,index) in chipListTow" :key="index"><view class="swiper_list" v-show="chipList.length>0"><view :class="[currentImage === n.id ? 'image_box_1' : 'image_box']"></view><image :class="currentImage===n.id&&'select_image'" class="swiper_slide_image":src="n.iconPath0" /></view></SwiperSlide></Swiper>//无法直接使用refconst swiperRef = ref(null)//必须在初始化的时候赋值才能使用slideToconst onSwiperInit = (swiper) => {swiperRef.value = swipersetTimeout(() => {swiperRef.value.slideTo(swiperIndex.value, 500, false)}, 100)}

2.在开启loop后  点击SwiperSlide切换 后乱跳

//更改前	<Swiper loop ref="swiperRef" class="swiper animate__animated animate__fadeIn" :modules="modules":slides-per-view="5" :centered-slides="true" :space-between="0" :grab-cursor="true"@swiper="onSwiperInit" @slide-change="changeSwiper" ><SwiperSlide v-for="(n,index) in chipListTow" :key="index" @click="clickSwiperItem"><view class="swiper_list" v-show="chipList.length>0"><view :class="[currentImage === n.id ? 'image_box_1' : 'image_box']"></view><image :class="currentImage===n.id&&'select_image'" class="swiper_slide_image":src="n.iconPath0" /></view></SwiperSlide></Swiper>//更改后<Swiper loop ref="swiperRef" class="swiper animate__animated animate__fadeIn" :modules="modules":slides-per-view="5" :centered-slides="true" :space-between="0" :grab-cursor="true"@swiper="onSwiperInit" @slide-change="changeSwiper" @click="clickSwiperItem"><SwiperSlide v-for="(n,index) in chipListTow" :key="index"><view class="swiper_list" v-show="chipList.length>0"><view :class="[currentImage === n.id ? 'image_box_1' : 'image_box']"></view><image :class="currentImage===n.id&&'select_image'" class="swiper_slide_image":src="n.iconPath0" /></view></SwiperSlide></Swiper>
//将click 给swiper  而不是SwiperSlide  获取其clickedIndex的值const clickSwiperItem = (e) => {swiperRef.value.slideTo(e.clickedIndex, 500, false);}


http://www.mrgr.cn/news/19533.html

相关文章:

  • 2024运维监控工具的普及得益于几个关键因素
  • Scratch 外观模块
  • 项目实战 ---- 商用落地视频搜索系统(7)---系统优化(1)
  • Latex安装--新手教程、遇到的问题
  • 国内超声波清洗机哪个品牌好?质量好的超声波清洗机推荐
  • Android Telephony总结
  • 2024年二级建造师考试题库及答案
  • 关于ETL的两种架构(ETL架构和ELT架构)
  • 在x86上拉取ARM架构的镜像
  • 多模态最新进展!单模态增益多模态学习,解决多模态和单模态学习目标梯度冲突问题
  • 骨传导耳机哪个牌子最好?硬核测评五大热门王牌骨传导耳机!
  • 长效静态代理IP推荐:天启代理IP的优势与应用
  • Android终端如何快速接入GB28181平台实现实时音视频回传
  • android java BufferedWriter writer 如果每次都在 原有的数据上追加数据怎么实现?就是先读取,然后再写入
  • 随时随地远程启动家里设备,极空间部署一键网络唤醒工具『UpSnap』
  • Java程序的运行
  • NSSCTF练习记录:[AFCTF 2018]Vigenère
  • AI 网关基于 IP 地理位置,增强 Prompt 修饰能力
  • Apache DolphinScheduler在Cisco Webex的应用与优化实践
  • 分享基于PDF.JS的移动端PDF阅读器代码