鍍金池/ 問答/HTML/ Nodejs報錯Cannot read property 'call' of u

Nodejs報錯Cannot read property 'call' of undefined

nodejs 微信公眾號開發(fā)

--------## 中間件wechat.js有個方法reply ##

Wechat.prototype.reply = function(){

var content=this.body;
var message=this.weixin;

var xml=util.tpl(content,message);
this.status=200;
this.type='application/xml';
this.body=xml;

}
module.exports = Wechat;

----------## 在g.js文件中實例化這個函數(shù)并調(diào)用 ##
var sha1 = require('sha1')
var Wechat = require('./wechat')
var getRawBody = require('raw-body')
var util = require('./util')
var weixin = require('../weixin')

module.exports = function(opts){

var wechat = new Wechat(opts)
console.log(wechat)
wechat.reply.call(this)

出現(xiàn)這樣的錯誤
TypeError: Cannot read property 'call' of undefined

  at D:\www\nodejs\Projects\wechat\wechat\g.js:63:17
  at <anonymous>
  at process._tickCallback (internal/process/next_tick.js:188:7)

并且 wechat.reply 打印是未定義

回答
編輯回答
陌如玉

中間件wechat.js中的wechat函數(shù)中return關(guān)鍵字刪除

2018年4月8日 11:31