my.connectSocket({
url: ‘wss://’+url地址,
header: {
'content-type': 'application/json'
},
success: (res) => {
console.log(res) //为true已经建立连接
},
fail: (res) => {
console.log(res)
}
});
websocket.send(“参数”);//向服务器发送消息
websocket.onopen = function (evt) {
//成功时回调函数
}
详情可参考阮一峰网络日志http://www.ruanyifeng.com/blog/2017/05/websocket.html