微信JSSDK 报错wx is not defined?

小程序 文章 2022-03-09 16:40 4027 0 全屏看文

AI助手支持GPT4.0

微信JSSDK 报错wx is not defined?WeChat JSSDK reports error wx is not defined?

微信JSSDK 报错wx is not defined?

使用的是微信JSSDK的npm包,版本是1.6.0,通过import引入到要使用的页面。因为在测试环境会报错导致白屏,经排查可能是wx JSSDK的原因,所以在wx.config之前打印了一下,发现是undefined。麻烦帮忙看下是什么原因。部分代码及报错截图如下。

The NPM package of wechat jssdk, version 1.6.0, is used. It is imported to the page to be used. Because an error will be reported in the test environment, resulting in a white screen. After investigation, it may be the cause of Wx jssdk, so in Wx Config was printed and found to be undefined. Please help to see what the reason is. Some codes and screenshots of error reporting are as follows.

回答:

八九:

你这没引入成功的嘛,打印wx都undefined了

余征金:感谢回复。这个不是每次都报错,而是有些时候进去会报错。
八九:要不你换一个引入方式,不要用npm Σ(⊙▽⊙"a
余征金:之前一直没出现这个问题,昨天突然开始出现这个。主要是我们这周五就要发版了,不好改了。
VBit:

换种方式

余征金:

忘记说明一下,就是并不是每次进入项目流程都会报错,而是有概率会出现。如果在当前页面刷新的话,基本上5次就会出现一次。

-EOF-

AI助手支持GPT4.0