JiKeBang
JiKeBang
  • 发布:2019-01-27 16:05
  • 更新:2019-08-02 11:38
  • 阅读:2709

【报Bug】uni.connectSocket() 返回的 SocketTask 的onMessage 无法绑定

分类:uni-app

let socket = uni.connectSocket({
url: wsUrl
});

socket.onMessage(function(res){
console.log('收到服务器内容:' + res.data);
});

H5 H5+都有问题
bug信息:
catch TypeError: wsSocket.onMessage is not a function
at Object.createWebSocket (VM45 pages-index-index.js:37)
at VueComponent.onLoad (VM45 pages-index-index.js:380)
at a (VM38 index.js:12067)
at s (VM38 index.js:12067)
at VueComponent.created (VM38 index.js:12067)
at callHook (VM38 index.js:18202)
at VueComponent.Vue._init (VM38 index.js:19933)
at new VueComponent (VM38 index.js:20099)
at createComponentInstanceForVnode (VM38 index.js:19606)
at init (VM38 index.js:19433)

2019-01-27 16:05 负责人:无 分享
已邀请:

最佳回复

DCloud_UNI_GSQ

DCloud_UNI_GSQ

加上回调即可,无回调参数时,返回的为 Promise
let socket = uni.connectSocket({
url: wsUrl,
success(){}
});

JiKeBang

JiKeBang (作者)

H5 H5+都有问题

  • DCloud_UNI_GSQ

    小程序上是否正常

    2019-01-30 10:45

  • JiKeBang (作者)

    这个我没测试 ,暂时只用到了h5 h5+ 你们直接不会都测试一下?

    2019-01-30 13:54

  • 5***@qq.com

    请问下解决了吗? 我也是这个问题

    2019-03-30 09:07

该问题目前已经被锁定, 无法添加新回复