fix: 修复动作卡片点击双触发导致跳 404
- 8 个页面 exercise-card 由 bind:tap 改为 catch:tap,拦截原生 tap 冒泡 避免一次点击被『自定义事件 + 原生冒泡』触发两次, 第二次 e.detail 无 id → navigateTo detail?id=undefined → 404 - 所有 onExercise 顶部加 id 守卫,无 id 直接 return - exercise-card 点击前校验 exercise.id,缺失不触发 - detail onLoad 的 id 为空时直接显示空态,不再发起错误请求
This commit is contained in:
@@ -69,6 +69,7 @@ Page({
|
||||
},
|
||||
|
||||
onExercise(e) {
|
||||
if (!e || !e.detail || !e.detail.id) return;
|
||||
wx.navigateTo({
|
||||
url: '/pages/detail/detail?from=collection&slug=' +
|
||||
encodeURIComponent(this.data.slug) + '&id=' + encodeURIComponent(e.detail.id)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<section-header eyebrow="EXERCISES" title="动作列表" subtitle="共 {{total}} 个动作" />
|
||||
<view class="grid" wx:if="{{exercises.length}}">
|
||||
<view class="grid__item" wx:for="{{exercises}}" wx:key="id">
|
||||
<exercise-card exercise="{{item}}" bind:tap="onExercise" />
|
||||
<exercise-card exercise="{{item}}" catch:tap="onExercise" />
|
||||
</view>
|
||||
</view>
|
||||
<view wx:elif="{{!loading}}" class="empty">该计划暂无动作</view>
|
||||
|
||||
Reference in New Issue
Block a user