小程序如何解决原型函数调用问题
发布于 5 年前 作者 lei69 3929 次浏览 来自 问答

var TeamTalkWebClient = function(config) {

  this.websocketUrl = config.wsurl;

  this.clientState = UserStatType.USER_STATUS_OFFLINE;

  this.logined = false;

  this.connect();

};

/**

* @description connet to server

*/

TeamTalkWebClient.prototype.connect = function() {

  if(!!this.websocket) {

    this.websocket.close();

  }

  this.websocket = new WebSocket(this.websocketUrl);

  bindWebsocketForClinet(this.websocket,this);

};

对于原型函数的定义,如何调用,用this.connect调用不了

回到顶部