uni-app ios17.4系统微信小程序canvas的@touchend事件失效 无法触发

uni-app ios17.4系统微信小程序canvas的@touchend事件失效 无法触发

操作步骤:

?

预期结果:

?

实际结果:

?

bug描述:

ios17.4系统,微信小程序中canvas的@touchend事件失效!无法触发。官方人员可以直接找一台苹果手机更新到最新系统试试


| 信息类型     | 内容                           |
|--------------|-------------------------------|
| 产品分类     | uni小程序SDK                  |
| 手机系统      | iOS                           |
| 手机系统版本号 | iOS 17                        |
| 手机厂商      | 苹果                          |
| 手机机型      | 所有机型                      |
| 页面类型     | vue                           |
| SDK版本号    | ?                             |

更多关于uni-app ios17.4系统微信小程序canvas的@touchend事件失效 无法触发的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

大量画板小程序无法正常使用!

更多关于uni-app ios17.4系统微信小程序canvas的@touchend事件失效 无法触发的实战教程也可以访问 https://www.itying.com/category-93-b0.html


不存在这个问题吧

在 iOS 17.4 系统中,uni-app 开发的微信小程序可能会出现 @touchend 事件失效的问题。这可能是由于系统更新带来的兼容性问题。以下是一些可能的解决方案和排查步骤:

1. 检查事件绑定方式

确保你在 canvas 组件上正确绑定了 @touchend 事件。例如:

<canvas canvas-id="myCanvas" @touchstart="handleTouchStart" @touchmove="handleTouchMove" @touchend="handleTouchEnd"></canvas>

2. 使用 bind 替代 @

在某些情况下,微信小程序可能对 @ 符号的事件绑定支持不够稳定,尝试使用 bind 替代 @

<canvas canvas-id="myCanvas" bindtouchstart="handleTouchStart" bindtouchmove="handleTouchMove" bindtouchend="handleTouchEnd"></canvas>

3. 检查事件处理函数

确保事件处理函数在 methods 中正确定义,并且函数名与绑定的事件名一致:

methods: {
  handleTouchStart(event) {
    console.log('Touch Start', event);
  },
  handleTouchMove(event) {
    console.log('Touch Move', event);
  },
  handleTouchEnd(event) {
    console.log('Touch End', event);
  }
}

4. 使用 catch 绑定事件

如果 bind 仍然无法触发事件,可以尝试使用 catch 绑定事件,catch 会阻止事件冒泡,有时可以解决事件无法触发的问题:

<canvas canvas-id="myCanvas" catchtouchstart="handleTouchStart" catchtouchmove="handleTouchMove" catchtouchend="handleTouchEnd"></canvas>

5. 检查微信开发者工具版本

确保你使用的微信开发者工具是最新版本,旧版本可能存在兼容性问题。

6. 检查 iOS 17.4 的已知问题

查看微信小程序官方文档或社区,确认是否有关于 iOS 17.4 的已知问题或临时解决方案。

7. 使用 touch 事件的替代方案

如果 @touchend 事件仍然无法触发,可以考虑使用 @touchmove@touchstart 事件来模拟 @touchend 的逻辑。例如,在 @touchmove 中记录触摸状态,并在触摸结束时手动触发逻辑。

8. 提交反馈

如果以上方法都无法解决问题,建议向微信小程序官方提交反馈,提供详细的复现步骤和代码,以便官方团队进行排查和修复。

示例代码

以下是一个完整的示例代码:

<template>
  <view>
    <canvas canvas-id="myCanvas" bindtouchstart="handleTouchStart" bindtouchmove="handleTouchMove" bindtouchend="handleTouchEnd"></canvas>
  </view>
</template>

<script>
export default {
  methods: {
    handleTouchStart(event) {
      console.log('Touch Start', event);
    },
    handleTouchMove(event) {
      console.log('Touch Move', event);
    },
    handleTouchEnd(event) {
      console.log('Touch End', event);
    }
  }
}
</script>

<style>
</style>
回到顶部