uni-app nvue在真机里使用swiper事件@animationfinish 无论如何detail.current都返回0

uni-app nvue在真机里使用swiper事件@animationfinish 无论如何detail.current都返回0

开发环境 版本号 项目创建方式
Windows - HBuilderX

产品分类:uniapp/App

PC开发环境操作系统:Windows

HBuilderX类型:正式

HBuilderX版本号:3.2.6

手机系统:iOS

手机系统版本号:iOS 13.4

手机厂商:苹果

手机机型:苹果12

页面类型:nvue

打包方式:云端

操作步骤:

  • 复现代码不用写了吧。就是简单的swiper

预期结果:

实际结果:


bug描述:

nvue在真机里使用swiper 事件[@animationfinish](/user/animationfinish) 无论如何detail.current都返回0
nvue在真机里使用swiper 事件[@animationfinish](/user/animationfinish) 无论如何detail.current都返回0
nvue在真机里使用swiper 事件[@animationfinish](/user/animationfinish) 无论如何detail.current都返回0  

在开发环境 代码在H5是可以的。0 -1 -2 都能正常返回序列
在真机里。永远都是 0

更多关于uni-app nvue在真机里使用swiper事件@animationfinish 无论如何detail.current都返回0的实战教程也可以访问 https://www.itying.com/category-93-b0.html

1 回复

更多关于uni-app nvue在真机里使用swiper事件@animationfinish 无论如何detail.current都返回0的实战教程也可以访问 https://www.itying.com/category-93-b0.html


这是一个已知的nvue平台差异问题。在iOS真机上,nvue的swiper组件使用@animationfinish事件时,确实存在detail.current始终返回0的bug。

问题分析:

  1. nvue的swiper组件在iOS平台上的@animationfinish事件实现存在缺陷
  2. 该问题仅出现在iOS真机环境,H5和开发工具模拟器表现正常
  3. @change事件在iOS真机上可以正常获取current值

临时解决方案: 建议暂时使用@change事件替代@animationfinish。虽然@change的触发时机略有不同,但在仿抖音这类应用中,@change通常能满足需求:

<swiper [@change](/user/change)="onSwiperChange">
  <!-- swiper-item内容 -->
</swiper>

<script>
export default {
  methods: {
    onSwiperChange(e) {
      const current = e.detail.current
      // 使用current值进行后续处理
    }
  }
}
回到顶部