求websocket中nodejs已经显示连接上,但是readystate还是0,急

 //声明连接,房间号,名称
    ws
    roomCount = 100
    name
    IP='ws://127.0.0.1:8888'

    // websocket建立连接
    link(){
        //建立连接
        this.ws = new WebSocket(this.IP)
        //连接成立触发
        this.ws.onopen = this.onopen()
}
        
onopen(){
        console.log('success connected')
        var randomScore = parseInt(Math.random()*3)
        console.log('parseInt(Math.random()*5)=============>'+randomScore)
        console.log(this.ws.readyState)
        while(true){
            if(this.ws.readyState==1){
                this.ws.send({type:0,score:randomScore})
                break
            }
        }
}

```}