我在controller写了个function,然后有在routes里面写了app.get它的routes,最后是在view中写到 button.btn(action=’route’) Click
为啥这个route没反映的? 求个例子……
5 回复
view-jade: button.btn.btn-primary(method="delete",action="/users/deleteUser/"+user.index) DEL
routes: app.del('/userAccount/deleteUser/:userId’,userAccount.deleteUser) app.param('userId’, userAccount.user)
controller - method: exports.deleteUser = function(req,res){ console.log(‘wanna del user.’) }
exports.user = function(req, res, next, id){ UserAccount .find({index:id}) .exec(function(err,user){ if(err) next(err) if(!user) next(new Error(‘no user of this id.’)) req.profile = user next() }) }