当前位置:网站首页>微信小程序接入百度统计报错 Cannot read property ‘mtj‘ of undefined
微信小程序接入百度统计报错 Cannot read property ‘mtj‘ of undefined
2022-06-28 18:30:00 【木头没有瓜】
参考文章微信小程序如何接入百度统计并且自定义事件分析_improvement-CSDN博客_百度统计 自定义事件
接入百度统计,遇到了几个坑
1、第一个坑——微信小程序后台配置了https://hmma.baidu.com域名却没有
登录微信公众平台,进入小程序的设置->开发设置->服务器域名,把https://hmma.baidu.com加入REQUEST合法域名。
由于公司的小程序已经接入了很多域名,所以我将https://hmma.baidu.com添加保存后,再重新进入查看,发现没有添加上,一度以为微信把百度拉黑了,最终发现是因为微信小程序后台会将域名排序,不是最后添加的就会显示在最后,https://hmma.baidu.com这个域名被排序到了中间
2、第二个坑——域名配置后,小程序控制台还是报https://hmma.baidu.com域名不是安全域名
这个简单,但是试了重新编译还不行,心想重启应用能解决80%的问题,重启后就好了
3、第三个坑——Cannot read property 'mtj' of undefined

脑子一万个草泥马,百分百按照教程配置的,怎么就报错了呢,到底是哪里不对呢
原来整个小程序只有一个 App 实例,是全部页面共享的。开发者可以通过 getApp 方法获取到全局唯一的 App 实例,获取App上的数据或调用开发者注册在 App 上的函数。
在app.js中的onLaunch钩子函数,此时实例还未创建,是访问不到实例的方法的,不常用原生开发导致的坑啊
边栏推荐
- Introduction to apifox
- 微软独家付费功能,也被完美解锁了
- moco挡板制作及运行成功
- Database comparison tool
- 获取当前日期0点及23点59时间戳
- How to design a business high performance and high availability computing architecture - job
- 浦发银行软件测试面试真题(小编面试亲测)
- Learning notes: how to time 10ms for 51 single chip microcomputer (STC89C52)
- Graphic system - 1 Layout loading
- Upload file list (repeated file names are marked with brackets)
猜你喜欢

如何从RHEL 8升级到RHEL 9

微软独家付费功能,也被完美解锁了

EasyExcel 学习笔记

刷题分析工具

Database mysql statement final review CTGU

Does face recognition test involve privacy and security issues? A foreign company was urgently stopped

Small program graduation project based on wechat mobile mall small program graduation project opening report function reference

curl: (56) Recv failure: Connection reset by peer

leetcode 1423. Maximum Points You Can Obtain from Cards(从牌中能得到的最大点数和)

PCB线路板布局和布线都有哪些设计要求?
随机推荐
Introduction to apifox
Applet graduation design based on wechat beauty salon technician appointment applet graduation design opening report function reference
正版ST-link/V2 J-LINK JTAG/SWD引脚定义和注意事项
深入解析kubernetes中的选举机制
手动备份和还原DHCP服务器
双功能交联剂丨Lumiprobe 磺基花青7二羧酸研究
Graphic system - 2 View drawing
Go, begin, end, for, after, instead of
声网 VQA:将实时互动中未知的视频画质用户主观体验变可知
A preliminary study of IO model
图形系统——1. 布局加载
Analysis of response parsing process of SAP ui5 batch request
打破学科之间壁垒的STEAM教育
中金财富开户安全吗?开过中金财富的讲一下
Chapter 2 processing files, cameras and GUI Cameo applications
Applet graduation project reservation based on wechat housekeeping service applet graduation project opening report function reference
China gaobang brand story: standing guard for safety, gaobang pays attention to
PMP怎么补考?补考费用是多少?
Three communication skills in software testing
Lumiprobe非荧光叠丨氮化物研究丨3-叠丨氮丙醇