-
Creator 版本: 3.8.3
-
目标平台: windows10
-
重现方式:调用WebSocket的addEventListener方法添加监听
-
首个报错: [ERROR]: JS: TypeError: this.wsInstance.addEventListener is not a function
-
之前哪个版本是正常的:
-
手机型号:
-
手机浏览器:
-
编辑器操作系统:
-
重现概率:
之前根据文档写WebSocket的消息监听时间绑定,使用的是这个代码:
this.wsInstance = new WebSocket(‘ws://localhost:8080’,[]);
// 下面会报错 [ERROR]: JS: TypeError: this.wsInstance.addEventListener is not a function
this.wsInstance.addEventListener(“message”, (event)=>{
console.log("Message from server ");
});
浏览器运行是没有问题的,但是编译在win10上运行是就会报错,会无法绑定该监听事件,应该改成以下语句,用onmessage来绑定事件,在浏览器和win10上运行都没问题
this.wsInstance.onmessage = (event)=>{
console.log("Message from server ");
};
同样onerror也是如此