-
Creator 版本:3.7.3
-
目标平台:android
-
重现方式:运行报错
-
首个报错: 2023-07-12 14:35:58.501 22855-22882/? D/Cocos: 14:35:58 [DEBUG]: JS: Success to load scene: db://assets/scene.scene
2023-07-12 14:35:58.510 22855-22882/? D/Cocos: 14:35:58 [DEBUG]: JS: 01
2023-07-12 14:35:58.523 22855-22882/? E/Cocos: 14:35:58 [ERROR]: JS: TypeError: WebSocket is not a constructor
TypeError: WebSocket is not a constructor
at g.start (assets/main/index.js
698) -
之前哪个版本是正常的:谷歌浏览器调试正常,上真机就报错,做一个纯websocket调用测试demo也报错
-
手机型号: 雷电模拟器9
-
手机浏览器:
-
编辑器操作系统:
-
重现概率: 100%
测试代码:
private socket:WebSocket;
onSocketOpen() {}
onReciveMsg() {}
onSocketClose1() {}
onSocketError() {}
start() {
let url = "ws://192.168.0.85:32167";
console.log("01")
this.socket = new WebSocket(url);
console.log("11")
this.socket.binaryType = "arraybuffer";
console.log("21")
this.socket.onopen = this.onSocketOpen.bind(this);
console.log("31")
this.socket.onmessage = this.onReciveMsg.bind(this);
console.log("41")
this.socket.onclose = this.onSocketClose1.bind(this);
console.log("51")
this.socket.onerror = this.onSocketError.bind(this);
}