Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

服务端socket.io @4 能用这个包吗? #105

Open
johnsmithsren opened this issue Feb 17, 2023 · 9 comments
Open

服务端socket.io @4 能用这个包吗? #105

johnsmithsren opened this issue Feb 17, 2023 · 9 comments

Comments

@johnsmithsren
Copy link

遇到了什么问题?

你的预期是什么?

截图:

项目版本号:�

  • Version [e.g. 22]

微信开发者工具

  • 版本号:[e.g. 22]
  • 电脑 OS:[e.g. Windows 10]

真机环境 (请完成填充下面的条码):

  • Device: [e.g. iPhone6]
  • OS 版本: [e.g. iOS8.1]
  • 微信版本 [e.g. 22]

附加信息:

@kingchen2008
Copy link

把代码下载下来,重新安装依赖包,我试过 用socket.io-client 4.1.3 包, 可以打包,可以使用。服务器端V4, 要求客户端版本最低是4.1.3.

@kingchen2008
Copy link

用socket.io-client 4.6.1打包,在微信小程序中使用,出现eval之类的错误。查看了socket.io-client源代码,没有发现有用eval之类的代码,可能没有找得更细。
TypeError: Cannot read property 'bind' of undefined
at a (weapp.socket.io4.6.1.wx.js:1)
at new q (weapp.socket.io4.6.1.wx.js:10)
at V (weapp.socket.io4.6.1.wx.js:10)
at Object.initSocketClient (initSocket.js:68)
at eval (app.js? [sm]:301)
at H (eval at n.call.document (runtime.js?devtools_ignore=true:1), :2:68639)
at eval (eval at n.call.document (runtime.js?devtools_ignore=true:1), :2:68861)
at C (eval at n.call.document (runtime.js?devtools_ignore=true:1), :2:38338)

@puzzle9
Copy link

puzzle9 commented Mar 30, 2023

高于 4.1.3 的版本好像因为打包问题 直接用不了

@rayyzhong
Copy link

用4.1.3能动,不过webpack build的 development mode可用,用production mode 就出错。
image

@rayyzhong
Copy link

@kingchen2008 老哥能不能贴一个可用版本的上来

@puzzle9
Copy link

puzzle9 commented Apr 22, 2023

weapp.socket.io.wx-4.4.3.zip

我记得打包的 prod 也行啊

@rayyzhong
Copy link

weapp.socket.io.wx-4.4.3.zip

我记得打包的 prod 也行啊

用你这个还是报一样的错,不过我找到了个方法,虽然大小会占用113KB。

https://github.com/rayyzhong/weapp.socket.io#using-with-socketio-v4-eg-v461

@puzzle9
Copy link

puzzle9 commented Apr 22, 2023

weapp.socket.io.wx-4.4.3.zip
我记得打包的 prod 也行啊

用你这个还是报一样的错,不过我找到了个方法,虽然大小会占用113KB。

https://github.com/rayyzhong/weapp.socket.io#using-with-socketio-v4-eg-v461

不会吧 我项目中用这个是正常的 没遇到这个错误
可以提供个能复现的demo吗

@kingchen2008
Copy link

kingchen2008 commented May 6, 2023

@kingchen2008 老哥能不能贴一个可用版本的上来
这个是用socket.io-client 4.1.3 打包生成的代码,可以使用。 其实就是把作者的代码下载下面,然后重新npm install依赖包,安装一下 socket.io-client 4.1.3 依赖包,再重新打包就生成这个我贴上来的js文件。

运行package.json文件里面的命令:
build:wechat

weapp.socket.io.wx.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants