微信小程序websocket为啥不支持onMessage直接赋值?
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));