list頁面沒有獲取到movies數組,找不到問題所在
list中的代碼如下:
extends ../layout
block content
????.container
????????.row
????????????table.table.table-hover.table-bordered
????????????????thead
????????????????????tr
????????????????????????th 電影名字
????????????????????????th 導演
????????????????????????th 國家
????????????????????????th 上映年份
????????????????????????//th 錄入時間
????????????????????????th 查看
????????????????????????th 更新
????????????????????????th 刪除
????????????????tbody
????????????????????each item in movies
????????????????????????tr(class="item-id-#{item._id}")
????????????????????????????td #{item.title}
????????????????????????????td #{item.doctor}
????????????????????????????td #{item.country}
????????????????????????????td #{item.year}
????????????????????????????//td #{moment(item.meta.createdAt).format("MM/DD/YYYY")}
????????????????????????????td: a(target="_blank" href="../movie/#{item._id}") 查看
????????????????????????????td: a(target="_blank" href="../admin/update/#{item._id}") 修改
????????????????????????????td
????????????????????????????????button.btn.btn-danger.del(type="button"
????????????????????????????????data-id="#{item._id}")刪除
app中的list模塊的代碼如下:
app.get("/admin/list",function(req,res){
????res.render("list",{
????????title:'imooc 列表頁',
????????movies:[{
????????????doctor:'尼古拉斯-趙四',
????????????country:'美國',
????????????title:'機械戰警',
????????????_id:1,
????????????year:2014,
????????????poster:'http://r3.yking.com/05160000530EEB63675839160D0B79D5',
????????????language:'英語',
????????????flash:'http://player.youku.com/player.php/sid/XNjA1Njc0NTUy/v.swf',
????????????summary:'這是一部前無古人后無來者的片子,影片中主要講述了一群機器人妄想統治????????????????地球但是地球突然停'
????????}]
????})
})
app中和list中都是movies,但是卻報錯
TypeError: e:\imooc\views\pages\list.jade:17
? ?15| th 刪除?
? ?16| tbody?
?> 17| each item in movies?
? ?18| tr(class="item-id-#{item._id}")?
? ?19| td #{item.title}?
? ?20| td #{item.doctor}?
Cannot read property 'length' of undefined
? ?at eval (eval at <anonymous>?
到底錯在哪里呢
2016-12-02
你試試都改成 movie
2016-12-02
? ? ?//td #{moment(item.meta.createdAt).format("MM/DD/YYYY")}
我們的注釋都是這樣的//-
jade中不能用//
2016-11-08
你先看看你的縮進有沒有問題,正常是這樣的