首页 > 其他分享 >关于does not have a method xx to handle event "tap"我有话要说

关于does not have a method xx to handle event "tap"我有话要说

时间:2024-01-25 18:46:46浏览次数:22  
标签:handle image openSettings k3u1fbpfcp xx ###### method png bindtap

前言
> 我正在对接微信小程序订阅消息功能,看了官方文档觉得挺简单的。于是踩坑开始了

###### 应该是这样简单的
```
wx.requestSubscribeMessage({
tmplIds: [''],
success (res) { }
})
```
###### 你直接调用会得到
`订阅失败 {errMsg: "requestSubscribeMessage:fail can only be invoked by user TAP gesture."}`

###### 根据这个错误,得到必须要用手动调用(这个要好好理解)。调整后你得到以下代码

```
<button open-type="openSetting" bindopensetting="openSettings">打开设置页</button>
这个按钮会直接打开授权设置页面,目前还不是你的业务范围(你会搜到的大部分答案)

第二种方式是这样绑定bindtap
<button >授权</button>
如果你也是用的uniAPP开发
methods: {
openSettings(){
wx.requestSubscribeMessage({
tmplIds: [''],
success (res) { }
})
}
}
```
###### 第一种方法,目前不需要,你需要的弹出订阅消息授权框

###### 于是方式二,你始终得到`Component "pages/index/home" does not have a method "openSettings" to handle event "tap".`

![image.png](https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/2f85e6eab3bf46e693219cf5b379c605~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=1011&h=214&s=34951&e=png&b=332b00)

然后开始各种网上找答案

![image.png](https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/7015765dad21496e86db26b3b6428456~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=2908&h=61&s=26884&e=png&b=d2e2fc)

###### 这里我也把看到的一些答案汇总
1. bindtap=" openSettings " 是否前后有空格
2. js文件不需要包一层methods,组件形式需要包一层【这里我挪进去挪出来试,无用】
3. bindtap="这里的函数不要带参数直接写函数名";如果要传参数使用data-xxx的形式传递
4. 在js中没有定义方法

以上都没有解决我的问题
###### 回到最原始的时候,微信要求该方法必须是用户调用,于是机灵了一下,不用bindtap直接用click。得到了我想要的结果。
`<button @click="openSettings()">打开</button>`

![image.png](https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/8883e121151145749748875d173a3ced~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=492&h=394&s=17500&e=png&b=fdfdfd)

###### 总结
这个功能很难吗?我还是觉得简单的,但是我却花了两个小时以上。原本半个小时不到就可以完成的功能

标签:handle,image,openSettings,k3u1fbpfcp,xx,######,method,png,bindtap
From: https://www.cnblogs.com/ifannie/p/17987896

相关文章

  • A Format Compliant Encryption Method for 3D Objects Allowing Hierarchical Decryp
    Abstract—Withtheincreasingpopularityof3Dobjectsinindustryandeverydaylife,3Dobjectsecurityhasbecomeessential.Whilethereexistsmethodsfor3Dselectiveencryption,whereaclear3Dobjectisencryptedsothattheresulthasthedesiredl......
  • XXL-JOB配置
    一、Docker运行#Docker地址:https://hub.docker.com/r/xuxueli/xxl-job-admin/(建议指定版本号)dockerpullxuxueli/xxl-job-admin:2.3.1dockerrun-it\-ePARAMS="--spring.datasource.url=jdbc:mysql://172.18.0.3:3306/xxl_job?useUnicode=true&characterEncodi......
  • git pull : 提示 can't lock ref 'xxxx' ,some local refs could not be update
    在执行gitpull操作时可能会遇到can'tlockref'xxxx',somelocalrefscouldnotbeupdate;tryrunninggitremotepruneorigintoremoveanyold,conflictingbranches。出现以上的问题的原因是本地所追踪的远程分支,与本地对应分支不同,导致的gitpull失败。如有一......
  • Discarded invalid param(s) "xxx" when navigating.路由params传值报错
    从VueRouter的2022-8-22更新后,无法使用name+params的方式进行传递,官方给出的说法是所以我采用了HistoryAPI的模式A组件import{useRouter}from"vue-router"letrouter=useRouter()constparams={title:'标题'}functiontoRouter(){router.push({name:......
  • Uncaught (in promise) ChunkLoadError: Loading chunk commons.xxxxxxxxx failed
    报错信息如下:Uncaught(inpromise)ChunkLoadError:Loadingchunkcommons.pages_index.pages_teacher_indexfailed. (error:http://localhost:3000/_nuxt/commons.pages_index.pages_teacher_index.js)发生情景:打开多标签时,Nuxt程序崩溃:我有一个vue、nuxt应用程序......
  • vue-helper 点击跳转插件 在 methods里面互相调用函数,会产生两个函数definitions ,然后
    vue-helper点击跳转插件在methods里面互相调用函数,会产生两个函数definitions,然后就回弹出框让你选择原因:换了台电脑,又从新配置下vscode"editor.gotoLocation.multipleTypeDefinitions":"goto","editor.gotoLocation.multipleReferences":"goto","editor.got......
  • sudo: unable to resolve host xxxx: Name or service not known
    前言在Linux环境中,我使用sudo执行命令,发生报错:sudo:unabletoresolvehostxxxx:Nameorservicenotknown解决这个错误通常发生在更改主机名后,使用sudo命令时出现问题。sudo命令会尝试解析主机名,但如果无法解析,就会出现"sudo:unabletoresolvehost"的错误。然而......
  • Python requests连接池超出错误urllib3.connectionpool:Connection pool is full disc
    今天在进行多线程请求的时候出现问题,但是是警告,不过会导致把其他请求给关闭掉,严重影响效率,在网上搜了一大堆都是说urllib3的,没有说requests的。WARNING:urllib3.connectionpool:Connectionpoolisfull,discardingconnection:450632824.shop.n.weimob.com.Connectionpools......
  • GD32F4xx FLASH存储
    一、GD32F4xx的内存GD32F4xx的内存结构由:主存储器、系统信息存储器、一次性编程区域和选项字节等4部分组成。主存储器:用来存放代码和数据常数(如const类型的数据)。分为2个块,块0分为12个扇区,前4个扇区为16KB大小,第五个扇区是64KB大小,剩下的7个扇区都是128K大......
  • 利用aop、拦截器HandlerInterceptor来实现接口限流,日志收集
    前言:aop是面向切面编程,通过预编译方式和运行期间动态代理实现程序功能的统一维护的一种技术。拦截器是web请求中一个请求周期中的一环就实现接口限流这个需求来说,用aop和HandlerInterceptor都可以来实现,就是在调用接口之前做一些约束而已。aop+自定义注解+Semaphore实现接口限流自......