name: 'Chat',
                  
                  
                      data() {
                  
                  
                          return {
                  
                  
                              socket: io('localhost:4000'),
                  
                  
                              handle: '',
                  
                  
                              message: '',
                  
                  
                              dataM: ''
                  
                  
                          }
                  
                  
                      },
                  
                  
                      methods: {
                  
                  
                          sendMessage() {
                  
                  
                              this.socket.emit('chat', {
                  
                  
                                  message: this.message,
                  
                  
                                  handle: this.handle
                  
                  
                              });
                  
                  
                              this.receiveMessage();
                  
                  
                          },
                  
                  
                          receiveMessage() {
                  
                  
                              this.socket.on('chat', function(data) {
                  
                  
                                  this.dataM = data.message;
                  
                  
                              })
                  
                  
                          }
                  
                  
                      }
                  
                  
                      
                  
                  
                  }
                  
                  
                
В receiveMessage контекст this потерян
Обсуждают сегодня