node.js - Nodejs报错Cannot read property 'call' of undefined
PHP中文网
PHP中文网 2017-06-29 10:09:20
0
3
1118

在中间件中这么写:
wechat.reply.call(this);
在wechat中的reply函数是这么写的:

Wechat.prototype.reply = function(){
    console.log('bbbbb');
    var content = this.body;
    var message = this.weixin;
    var xml = util.tpl(content,message)

    console.log(xml);
    this.status = 200
    this.type = 'application/xml'
    this.body = xml
    return
}

然后就报错

TypeError: Cannot read property 'call' of undefined
      at Object.<anonymous> (C:\www\koa\wechat\wechat\g.js:54:16)
      at Generator.next (<anonymous>)
      at onFulfilled (C:\www\koa\wechat\node_modules\co\index.js:65:19)
      at process._tickCallback (internal/process/next_tick.js:109:7)
      

话说,call函数不是在原生js中就能用吗,为什么我在调用的时候报错了呢?

而且,百度了一下,有这种错误的人特别少……
问大神:通常是什么时候会报这个错?报错的原因是什么?

PHP中文网
PHP中文网

认证高级PHP讲师

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!