麦狐人
麦狐人
  • 发布:2023-05-23 10:15
  • 更新:2023-06-02 15:23
  • 阅读:161

如何为dom元素添加touchstart事件?

分类:uni-app

我的目的是为body元素添加一个touchstart事件,但是无法获取到body元素

this.$nextTick(() => {  
                                        uni.createSelectorQuery().in(this).select(  
                                            'body').addEventListener("touchstart",  
                                            function(e) {  
                                                console.log('触摸事件')  
                                                pub.userClick();  
                                            });  
                                    })Ï

但是报错:[Vue warn]: Error in event handler for "view.vdSyncCallback": "TypeError: uni.createSelectorQuery(...).in(...).select(...).addEventListener is not a function"
10:12:52.398 (found <Root>)

2023-05-23 10:15 负责人:无 分享
已邀请:
piaoyi_UI

piaoyi_UI - 【插件开发】【专治疑难杂症】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=193663(微信搜索飘逸科技UI小程序直接体验)】【骗子请绕道】问题咨询请加QQ群:120594820,代表作灵感实用工具小程序

直接html上加

  • 麦狐人 (作者)

    项目文件里没有html文件,只有一个App.vue

    2023-05-23 10:28

深海智行

深海智行 - 专注前端培训

在当前组件下是不可能查找到body的

要回复问题请先登录注册