Sending anonymous functions through socket.io?

前端 未结 2 1610
日久生厌
日久生厌 2020-12-18 10:42

I want to create a client-side function that can receive and execute arbitrary commands using client-side variables. I will be sending these functions from my server by usin

2条回答
  •  轮回少年
    2020-12-18 11:27

    You can't send literal JavaScript functions and expect it to work. You'll need to stringify the function first (i.e put it within a set of quotes), then eval the string on the client side.

提交回复
热议问题