原因:元素点击事件在子元素上有绑定,父元素上也有绑定会形成冒泡事件;
原生小程序:
bind:tap:会冒泡;
<view bind:tap="gotoDetail"><image :src="{{ item2.img }}" mode="aspectFill"></image>
</view>
catch:tap:阻止冒泡;
<view catch:tap="gotoDetail"><image :src="{{ item2.img }}" mode="aspectFill"></image>
</view>
uniapp:
@click:会冒泡;
<view @click="gotoDetail(item.id, item2.action_id)"><image :src="item2.img" mode="aspectFill"></image>
</view>
@click.stop:阻止冒泡;
<view @click.stop="gotoDetail(item.id, item2.action_id)"><image :src="item2.img" mode="aspectFill"></image>
</view>