当前位置:网站首页>[JS Framework] Failed to execute the callback function:

[JS Framework] Failed to execute the callback function:

2022-06-24 18:02:00 mb60b79a6396b63


Recently in use uniapp When doing the Bluetooth function , Because it is necessary to realize disconnection and reconnection , Run into some problems .

uniapp Background threads are not supported ,worker This thing is divided into platforms , So it uses setTimeout The callback method implements reconnection . Report mistakes as headlines :

The following usage is not rigorous , although html We often use this on the page .

       
setTimeout(func(),2000)
  • 1.

  Changed to the following

       
setTimeout(function(){
return func()
},2000)
  • 1.
  • 2.
  • 3.

  That's all right. .

You need to declare in the form of a closure , Otherwise, there will be null pointer problems .


原网站

版权声明
本文为[mb60b79a6396b63]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202211511279767.html