W3Cschool
恭喜您成為首批注冊用戶
獲得88經驗值獎勵
解釋:監(jiān)聽 WebSocket 錯誤
Function callback
<button type="primary" bindtap="onSocketError">點擊打開websocket事件并監(jiān)聽錯誤事件</button>
Page({
onSocketError() {
swan.onSocketError(function(res) {
swan.showModal({
title: '監(jiān)聽到webSocket連接出錯',
content: JSON.stringify(res)
});
console.log('WebSocket連接打開出錯', res);
});
swan.connectSocket({
url: 'wss://echo.websocket.org',
success: res => {
console.log('connectSocket success', res);
},
fail: err => {
console.log('connectSocket fail', err);
}
});
}
});
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: