在socket.io中是否允许数组发出函数? [英] Are arrays allowed in the socket.io emit function?

查看:77
本文介绍了在socket.io中是否允许数组发出函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 socket.io 发射函数中发送对象数组?

Is it possible to send arrays of objects in the socket.io emit function?

例如,

io.emit("message", [{data: 123},{data: 456}]);


推荐答案

,是。

您几乎可以发送任何类型,并且可以在其他类型中嵌套任何类型:

You can send almost any type, and can nest any type within another type:


  • 字符串

  • 数字 123

  • 数组 []

  • 对象 {}

  • 布尔值是/否

  • 未定义未定义

  • null

  • Blobs Blob( )

  • 文件 File()

  • 组合 [{ example:123},{bool:true},[1,2,undefined],blob]

  • Strings ""
  • Numbers 123
  • Arrays []
  • Objects {}
  • Booleans true/false
  • Undefined undefined
  • Null null
  • Blobs Blob()
  • Files File()
  • Combinations [{"example:123},{bool:true},[1,2,undefined],blob]

还有其他。希望对您有所帮助!

And others. Hope that helps!

这篇关于在socket.io中是否允许数组发出函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆