角度websocket插件正在瀏覽器中工作。但在移動設備生成apk之後,它不能正常工作,它顯示錯誤。科爾多瓦websocket插件也無法正常工作,它顯示錯誤代碼1006.任何人都可以幫助我。我是新來的離子。cordova websocket插件顯示錯誤代碼1006和角度websocket插件顯示isTrusted true錯誤
document.addEventListener('deviceready', function() {
var ws = new WebSocket('ws://197.164.1.12:8080/example/2');
ws.onopen = function() {
alert('open');
this.send('hello');
};
ws.onmessage = function (event) {
alert(event.data);
this.close();
};
ws.onerror = function (event) {
alert('error occurred!'+JSON.stringify(event));
};
ws.onclose = function (event) {
alert('onclose code=' + event.code);
};
ws.close = function (event) {
alert('close code=' + JSON.stringify(event));
alert('onclose code=' + event.code);
};
}, false);
你可以發佈錯誤內容 –