美文网首页
uni-app nvue 阻止事件冒泡 .stop 修饰符不生效

uni-app nvue 阻止事件冒泡 .stop 修饰符不生效

作者: 深渊凝视 | 来源:发表于2022-08-02 18:52 被阅读0次
如下图,在事件绑定是使用了.stop事件修饰符,在H5,小程序,普通app项目中起作用,但在nvue项目中无效
 <image @click.stop="clickaddress(item, $event)" class="event-info-list-right-image"
                                src="../../static/img/nearby_icon_13.png">
                            </image>
解决方案:在事件中添加条件编译即可
// #ifdef APP-NVUE
e.stopPropagation()
// #endif
/* 跳转定位地点 */
        clickaddress(item, e) {
            // #ifdef APP-NVUE
            e.stopPropagation()
            // #endif
            
            uni.openLocation({
                latitude: Number(item.lat),
                longitude: Number(item.lng),
                success: function () {
                    console.log('success');
                }
            });
        },

相关文章

网友评论

      本文标题:uni-app nvue 阻止事件冒泡 .stop 修饰符不生效

      本文链接:https://www.haomeiwen.com/subject/tcejwrtx.html