首页 > 前端技术 > 小程序报错{“errMsg”:”hideLoading:fail:toast can’t be found”}
2021
02-05

小程序报错{“errMsg”:”hideLoading:fail:toast can’t be found”}

微信Version 7.0.13测试版,会出现这个问题。之前报错没有注意,后来导致一个bug出现。

官方说:注意

wx.showLoading 和 wx.showToast 同时只能显示一个
wx.showLoading 应与 wx.hideLoading 配对使用

看了几个帖子,解决方法如下

定义一个变量 isShowLoading = false;

调用 wx.showLoading 时候赋值 isShowLoading为true,并调用showLoading

调用 wx.hideLoading 时候先判断 isShowloading,为true才能执行,否则不执行。

调用 wx.showToast 时候判断 isShowloading,为true就执行 wx.hideLoading ,否则不执行。接着执行showToast函数。

至此,我测试时候调试器中也不再报 errMsg”:”hideLoading:fail:toast can’t be found”?bug也修复好了。仅供参考

最后编辑:
作者:管理员
这个作者貌似有点懒,什么都没有留下。