开发工具上能完美运行的在手机上有问题
发布于 5 年前 作者 xiuyingchang 11203 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

开发端成功运行sendsocketmessage并回调success函数,附上函数

wx.connectSocket({

//url: ‘url:test’,

url: ‘ws://www.stserver.xyz:30000’,

header: {

‘Sec-WebSocket-Protocol’: this._protocols    //need add this

},

})

wx.onSocketError(function (res) {

console.log(‘WebSocket连接打开失败,请检查!’)

})

wx.onSocketOpen(function (res) {

that.setData({

socketOpen:true

})

wx.sendSocketMessage({

data: [that.data.phone + ’ ’ + that.data.password],

success: (res) => {

//console.log(res.data)

console.log(‘收到服务器内容:’ + res.data)

},

fail: (res) =>{

console.log(‘失败:’+res.data);

}

})

})

手机端是这样:

  • 预期表现

服务器应该受到小程序发送来的数据并返回success函数但是却回调了fail函数。

  • 复现路径
  • 提供一个最简复现 Demo

wx11619ba9c74bf4ac

1 回复

你好,请提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

回到顶部