Taro.onSocketError(callback)
Listens on the WebSocket error event.
Type
(callback: (result: Callback) => void) => void
Parameters
Callback
The callback function for the WebSocket error event.
(result: CallbackResult) => void
Property | Type |
---|---|
result | CallbackResult |
CallbackResult
Property | Type | Description |
---|---|---|
errMsg | string | Error message |
Sample Code
Taro.connectSocket({
url: 'test.php'
})
Taro.onSocketOpen(function (res){
console.log('WebSocket connection is open!')
})
Taro.onSocketError(function (res){
console.log('WebSocket connection failed to open, please check!')
})
API Support
API | WeChat Mini-Program | Baidu Smart-Program | Alipay Mini-Program | H5 | React Native |
---|---|---|---|---|---|
Taro.onSocketError | ✔️ | ✔️ | ✔️ |