index.uvue 文件代码
import {connectSocket} from "@/websocket/ws.uts"
export default {
onLoad(){
connectSocket()
}
}
websocket/ws.uts 文件
export function connectSocket(){
uni.connectSocket({
url: "ws://xxx.xx",
success: (result:ConnectSocketSuccess):void => {
console.log(result)
}
})
}
GV000 (作者)
项目存在pages/chat/index.uvue文件里引入外部ws.uts文件的
2023-12-19 13:02
GV000 (作者)
目录结构 pages/chat/index.uvue websocket/ws.uts
2023-12-19 13:04
DCloud_UNI_FXY
回复 GV000: 发一个可重现的demo
2023-12-20 15:44