刚刚接触cocos,不是很了解在网络的请求里想要修改UI的话cocos应该怎么操作么?ws的请求好像是异步的,不可以在异步里直接调用方法,提示refreshUI方法undefined。
start() {
var ws = new WebSocket(“ws://localhost:8080”);
ws.onopen = function (event) {
console.log("onOpen");
};
ws.onmessage = function (event) {
refreshUI(event.data);
};
ws.onerror = function (event) {
console.log("onError");
};
ws.onclose = function (event) {
console.log("closed.");
};
},
文字缩进4格