遇到相同问题https://developers.weixin.qq.com/community/develop/doc/000c60c0e18858369b6cb2a5f51000?highLine=TCP
TCP socket API开放了,感觉能大派用场,但为何却无法使用?真机调试,iOS14.6,微信版本8.0.7,SDK版本2.18.0 使用canUseTcp测试API返回false: wx.canIUse("createTCPSocket") 按照文档使用API: const tcp = wx.createTCPSocket() tcp.connect({address: '192.168.42.1', port: 7878}) 直接报错: VM13:2 SystemError (appServiceSDKScriptError) this hasn't been initialised - super() hasn't been called ReferenceError: this hasn't been initialised - super() hasn't been called at r (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:1277) at o (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:6955) at new n (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:2232971) at Object.FS (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:2234061) at Object.T.l.forEach.t.<computed> (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:1167452) at Object.eval (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:786902) at Object.eval (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:2397414) at < at wx.createTCPSocket> at Object.eval (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:115620) at qi.onTapConnectButton (weapp:///pages/home/index.js:13:18) errorReport @ VM13:2 eval @ VM13:2 c @ VM13:2 eval @ VM13:2 onTapConnectButton @ index.js:8 i.safeCallback @ VM13:2 eval @ VM13:2 Dn @ VM13:2 eval @ VM13:2 y @ VM13:2 eval @ VM13:2 eval @ VM13:2 S @ VM13:2 Ce @ runtime.js?devtools_ignore=true:1 eval @ VM56:1 te @ runtime.js?devtools_ignore=true:1 je @ runtime.js?devtools_ignore=true:1 Be.Je.onmessage @ runtime.js?devtools_ignore=true:1 VM13:2 MiniProgramError Cannot read property 'connect' of undefined TypeError: Cannot read property 'connect' of undefined at qi.onTapConnectButton (weapp:///pages/home/index.js:14:9) at Object.i.safeCallback (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:2431454) at eval (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:2613138) at Dn (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:2559544) at eval (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:2613066) at y (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:2510002) at eval (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:2510346) at eval (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:1195510) at Object.S (eval at n.call.document (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:14643), <anonymous>:2:79201) at Ce (http://127.0.0.1:12555/remote-debug/runtime.js?devtools_ignore=true:1:21747) errorReport @ VM13:2 thirdErrorReport @ VM13:2 eval @ VM13:2 eval @ VM13:2 i.safeCallback @ VM13:2 i.call @ VM13:2 o @ VM13:2 i.safeCallback @ VM13:2 eval @ VM13:2 Dn @ VM13:2 eval @ VM13:2 y @ VM13:2 eval @ VM13:2 eval @ VM13:2 S @ VM13:2 Ce @ runtime.js?devtools_ignore=true:1 eval @ VM56:1 te @ runtime.js?devtools_ignore=true:1 je @ runtime.js?devtools_ignore=true:1 Be.Je.onmessage @ runtime.js?devtools_ignore=true:1 是我哪里搞错了吗?
2021-07-19