为什么 点击 点击事件会出现 Cannot read property 'type' of undefined
node --harmony app.js
Listening: 1234
{ errcode: 0, errmsg: 'ok' }
{ xml:
{ ToUserName: [ 'gh_a1fa4a51afca' ],
FromUserName: [ 'omt_gw-lQqAVp4-o1p_lQmxD0vC0' ],
CreateTime: [ '1463300037' ],
MsgType: [ 'event' ],
Event: [ 'CLICK' ],
EventKey: [ 'menu_click' ] } }
{ ToUserName: 'gh_a1fa4a51afca',
FromUserName: 'omt_gw-lQqAVp4-o1p_lQmxD0vC0',
CreateTime: '1463300037',
MsgType: 'event',
Event: 'CLICK',
EventKey: 'menu_click' }
TypeError: Cannot read property 'type' of undefined
at Object.exports.tpl (C:\Users\liuhui\Desktop\wechat\wechat\util.js:70:16
)
at Object.Wechat.reply (C:\Users\liuhui\Desktop\wechat\wechat\wechat.js:10
32:17)
at Object.<anonymous> (C:\Users\liuhui\Desktop\wechat\wechat\g.js:59:17)
at next (native)
at Object.<anonymous> (C:\Users\liuhui\Desktop\wechat\node_modules\koa-com
pose\index.js:28:19)
at next (native)
at onFulfilled (C:\Users\liuhui\Desktop\wechat\node_modules\co\index.js:65
:19)
at process._tickCallback (internal/process/next_tick.js:103:7)
点击弹出系统拍照或相册上传照片时不了... 也出现
Cannot read property 'type' of undefined
at Object.exports.tpl
node --harmony app.js
Listening: 1234
{ errcode: 0, errmsg: 'ok' }
{ xml:
{ ToUserName: [ 'gh_a1fa4a51afca' ],
FromUserName: [ 'omt_gw-lQqAVp4-o1p_lQmxD0vC0' ],
CreateTime: [ '1463300201' ],
MsgType: [ 'event' ],
Event: [ 'pic_photo_or_album' ],
EventKey: [ 'pic_photo_album' ],
SendPicsInfo: [ [Object] ] } }
{ ToUserName: 'gh_a1fa4a51afca',
FromUserName: 'omt_gw-lQqAVp4-o1p_lQmxD0vC0',
CreateTime: '1463300201',
MsgType: 'event',
Event: 'pic_photo_or_album',
EventKey: 'pic_photo_album',
SendPicsInfo: { Count: '1', PicList: { item: [Object] } } }
{ item: { PicMd5Sum: 'a66c0a1a00ee968a71062c8cbb669719' } }
1
您点击了菜单中: pic_photo_album
{ xml:
{ ToUserName: [ 'gh_a1fa4a51afca' ],
FromUserName: [ 'omt_gw-lQqAVp4-o1p_lQmxD0vC0' ],
CreateTime: [ '1463300201' ],
MsgType: [ 'image' ],
PicUrl: [ 'http://mmbiz.qpic.cn/mmbiz/gVXjzuYWiaxKgQnHLnL1bibSOQdtaicn1ha5L
8gibYx3VL0ztTmnUl8rFCcy08tCo6cdrr0QpDbiaPOCtdesxXmmKQQ/0' ],
MsgId: [ '6284826507935546992' ],
MediaId: [ 'HpsjyipKwN54o1d4q72QRka3TfZuKKB3S7cLE7ytyzmu2hiYBtP2nobkKso2mOl
a' ] } }
{ ToUserName: 'gh_a1fa4a51afca',
FromUserName: 'omt_gw-lQqAVp4-o1p_lQmxD0vC0',
CreateTime: '1463300201',
MsgType: 'image',
PicUrl: 'http://mmbiz.qpic.cn/mmbiz/gVXjzuYWiaxKgQnHLnL1bibSOQdtaicn1ha5L8gibY
x3VL0ztTmnUl8rFCcy08tCo6cdrr0QpDbiaPOCtdesxXmmKQQ/0',
MsgId: '6284826507935546992',
MediaId: 'HpsjyipKwN54o1d4q72QRka3TfZuKKB3S7cLE7ytyzmu2hiYBtP2nobkKso2mOla' }
undefined
TypeError: Cannot read property 'type' of undefined
at Object.exports.tpl (C:\Users\liuhui\Desktop\wechat\wechat\util.js:70:16
)
at Object.Wechat.reply (C:\Users\liuhui\Desktop\wechat\wechat\wechat.js:10
32:17)
at Object.<anonymous> (C:\Users\liuhui\Desktop\wechat\wechat\g.js:59:17)
at next (native)
at Object.<anonymous> (C:\Users\liuhui\Desktop\wechat\node_modules\koa-com
pose\index.js:28:19)
at next (native)
at onFulfilled (C:\Users\liuhui\Desktop\wechat\node_modules\co\index.js:65
:19)
at process._tickCallback (internal/process/next_tick.js:103:7)
exports.tpl = function(content, message) { //暴露出tpl var info = {} var type = 'text' var fromUserName = message.FromUserName var toUserName = message.ToUserName if (Array.isArray(content)) { type = 'news' } console.log(content) type = content.type || type info.content = content info.createTime = new Date().getTime() info.msgType = type info.toUserName = fromUserName info.fromUserName = toUserName return tpl.compiled(info) }
console.log(content) 输出 undefined