亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

遇到了一個問題: Cannot read property 'length' of undefined

當在首頁點擊進入詳情頁的時候,跳出以下錯誤,不知道是不是跟express的版本有關系,我現在的express已經不包含body-parser,目前這個包需要獨立安裝,麻煩看看,謝謝。

TypeError: /root/nodejsWar/imooc/views/pages/index.jade:6
? ?4| .container
? ?5| .row
?> 6| - each item in movies
? ?7| .col-md-2
? ?8| .thumbnail
? ?9| a(href="/movie/#{item._id}")

Cannot read property 'length' of undefined
? ?at eval (eval at exports.compile (/root/nodejsWar/imooc/node_modules/jade/lib/index.js:218:8), <anonymous>:103:31)
? ?at eval (eval at exports.compile (/root/nodejsWar/imooc/node_modules/jade/lib/index.js:218:8), <anonymous>:224:4)
? ?at eval (eval at exports.compile (/root/nodejsWar/imooc/node_modules/jade/lib/index.js:218:8), <anonymous>:249:22)
? ?at res (/root/nodejsWar/imooc/node_modules/jade/lib/index.js:219:38)
? ?at Object.exports.renderFile (/root/nodejsWar/imooc/node_modules/jade/lib/index.js:380:38)
? ?at Object.exports.renderFile (/root/nodejsWar/imooc/node_modules/jade/lib/index.js:370:21)
? ?at View.exports.__express [as engine] (/root/nodejsWar/imooc/node_modules/jade/lib/index.js:417:11)
? ?at View.render (/root/nodejsWar/imooc/node_modules/express/lib/view.js:128:8)
? ?at tryRender (/root/nodejsWar/imooc/node_modules/express/lib/application.js:640:10)
? ?at Function.render (/root/nodejsWar/imooc/node_modules/express/lib/application.js:592:3)

正在回答

3 回答

你要貼出是從哪取的length 才能找到錯誤啊 看起來是movies的錯誤

0 回復 有任何疑惑可以回復我~
#1

慕圣8495798 提問者

已解決,謝謝!
2017-06-16 回復 有任何疑惑可以回復我~

檢查app里面 detail的路由,不要重復定義index的路由

0 回復 有任何疑惑可以回復我~

我也是each item in movies這句報錯,怎么解決噠?

0 回復 有任何疑惑可以回復我~
#1

慕運維0461344

我也是這個報錯,然后檢查一下你的入口js文件,就是老師案例里的app.js里面對這個主頁傳入的對象是movie還是movies,要對應的
2018-06-14 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
node+mongodb 建站攻略(一期)
  • 參與學習       91828    人
  • 解答問題       921    個

帶你完整實現一個從前端到后端的項目,初中級前端開發工程師必學課程

進入課程

遇到了一個問題: Cannot read property 'length' of undefined

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號