美文网首页
微信小程序长连接

微信小程序长连接

作者: 绿啊绿啊绿刺猬 | 来源:发表于2019-02-15 10:02 被阅读6次

    官方文档:https://developers.weixin.qq.com/miniprogram/dev/api/wx.connectSocket.html

    wx.connectSocket({
          url: 'ws://192.168.18.9/egoshe-api/client/1',
          header: {
            'content-type': 'application/json'
          },
          protocols: [],
          method: 'GET',
          success:function(res){
            console.log(res)
    
          }
        })
        wx.onSocketMessage(function (res) {
          console.log("收到服务器内容:" + res.data)
          var swiper=[];
          swiper.push(res.data)
          that.setData({
            swiper: swiper
          })
          console.log(swiper)
        })
    

    emmmmm.........只记得是年前要总结来着。。。已经具体忘了是什么意思来着。。。这样子写是可以请求到的,就先记录在这里啦。

    相关文章

      网友评论

          本文标题:微信小程序长连接

          本文链接:https://www.haomeiwen.com/subject/qffpeqtx.html