看到好多人提到這個問題 '_id' of undefined 求大神解決啊
TypeError: C:\Users\Administrator\WebstormProjects\imooc\views\pages\admin.jade:7
? ?5| ? ? ? ? .row?
? ?6| ? ? ? ? ? ? form.form-horizontal(method="post", action="/admin/movie/new")?
?> 7| ? ? ? ? ? ? ? ? input(type="hidden",name="movie[_id]", value="#{movie._id}")?
? ?8| ? ? ? ? ? ? ? ? .form-group?
? ?9| ? ? ? ? ? ? ? ? ? ? label.col-sm-2.control-label(for="inputTitle") 電影名字?
? ?10| ? ? ? ? ? ? ? ? ? ? .col-sm-10?
Cannot read property '_id' of undefined
? ?at eval (eval at <anonymous> (C:\Users\Administrator\WebstormProjects\imooc\node_modules\jade\lib\index.js:218:8), <anonymous>:100:88)
? ?at eval (eval at <anonymous> (C:\Users\Administrator\WebstormProjects\imooc\node_modules\jade\lib\index.js:218:8), <anonymous>:292:22)
? ?at res (C:\Users\Administrator\WebstormProjects\imooc\node_modules\jade\lib\index.js:219:38)
? ?at Object.exports.renderFile (C:\Users\Administrator\WebstormProjects\imooc\node_modules\jade\lib\index.js:380:38)
? ?at Object.exports.renderFile (C:\Users\Administrator\WebstormProjects\imooc\node_modules\jade\lib\index.js:370:21)
? ?at View.exports.__express [as engine] (C:\Users\Administrator\WebstormProjects\imooc\node_modules\jade\lib\index.js:417:11)
? ?at View.render (C:\Users\Administrator\WebstormProjects\imooc\node_modules\express\lib\view.js:126:8)
? ?at tryRender (C:\Users\Administrator\WebstormProjects\imooc\node_modules\express\lib\application.js:639:10)
? ?at EventEmitter.render (C:\Users\Administrator\WebstormProjects\imooc\node_modules\express\lib\application.js:591:3)
? ?at ServerResponse.render (C:\Users\Administrator\WebstormProjects\imooc\node_modules\express\lib\response.js:961:7)
? ?at C:\Users\Administrator\WebstormProjects\imooc\app.js:125:9
? ?at Layer.handle [as handle_request] (C:\Users\Administrator\WebstormProjects\imooc\node_modules\express\lib\router\layer.js:95:5)
? ?at next (C:\Users\Administrator\WebstormProjects\imooc\node_modules\express\lib\router\route.js:131:13)
? ?at Route.dispatch (C:\Users\Administrator\WebstormProjects\imooc\node_modules\express\lib\router\route.js:112:3)
? ?at Layer.handle [as handle_request] (C:\Users\Administrator\WebstormProjects\imooc\node_modules\express\lib\router\layer.js:95:5)
? ?at C:\Users\Administrator\WebstormProjects\imooc\node_modules\express\lib\router\index.js:277:22
2017-07-31
我也是,還是有錯啊
2016-10-21
接上句,還是有錯
2016-10-21
樓主解決了嗎,我加了app.use(bodyParser.urlencoded({extended:true})); ?app.use(bodyParser.json());
2016-03-31
最主要的是?extended:true
2016-03-27
這個是body-parser導致的
先安裝body-parser
然后
代碼如下
在app.js中
var bodyParser=require('body-parser');
app.use(bodyParser.urlencoded({extended:true}));