支付宝小程序使用uni.connectSocket返回undefined 问题描述支付宝小程序使用uni.connectSocket没有按预期返回socketTask 对象按官方文档写的是可以在支付宝小程序使用的但是测试了不行。varsocketTaskuni.connectSocket({url:wss://www.example.com/socket,//仅为示例并非真实接口地址。complete:(){},});解决方法用全局方法实现。代码示例uni.connectSocket({url:fullUrl,success:(){this.setupSocketListeners();},fail:(err){console.error(Connect WebSocket failed:,err);this.onError?.(err);this.tryReconnect();},});privatesetupSocketListeners():void{uni.onSocketOpen((){});uni.onSocketMessage((res:any){});uni.onSocketClose((){});uni.onSocketError((err:any){});}