https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.onMessage.html
不支持赋值监听:
this.socketTask.onOpen = this.onopen.bind(this);
this.socketTask.onError = this.onerror.bind(this);
this.socketTask.onClose = this.onclose.bind(this);
this.socketTask.onMessage = this.onmessage.bind(this);
需要注册回调函数来监听:
this.socketTask.onOpen(() => this.onopen());
this.socketTask.onError(res => this.onerror(res));
this.socketTask.onClose(() => this.onclose());
this.socketTask.onMessage(res => this.onmessage(res));
这个是api设计上的问题,算不上bug
是需要自己用EventEmitter封装吗?