如:TypeError: Cannot read property 'language' of undefined,
reportJSException >>>> exception function:createInstanceContext, exception:white screen cause create instanceContext failed,check js stack ->Uncaught ReferenceError: process is not defined
打包白屏等问题
1,降低版本 npm i mqtt@3
- pc端是ws,移动端是wx
3.main.js中加,处理报错:TypeError: socketTask.onOpen is not a function
// #ifndef MP
// 处理 wx.connectSocket promisify 兼容问题,强制返回 SocketTask
uni.connectSocket = (function(connectSocket) {
return function(options) {
options.success = options.success || function() {}
return connectSocket.call(this, options)
}
})(uni.connectSocket)
// #endif
4.mqtt引入路径要变: import * as mqtt from 'mqtt/dist/mqtt';
参考地址:
https://blog.csdn.net/tengyuxin/article/details/132606767
https://blog.csdn.net/song_song0927/article/details/136388233