我有这样的控制器api/meeting/meeting.controller.coffee
class Talker
constructor: (@name) ->
talk: ->
console.log "Talker name is" + @name
module.exports.meeting = (req, res, next) ->
talker = new Talker 'Bob'
talker.talk
这是我在index.coffee
controller = require './meeting.controller'
router.post('/', controller.meeting );
这与[{1}}:
相关联routes.js
现在布线和路由工作正常,但类中的console.log永远不会打印到我的CLI。知道怎么解决吗?
答案 0 :(得分:0)
这是一个意图和方法调用错误。这是它的工作原理:
class Talker
constructor: (@name) ->
talk: ->
console.log "Talker name is" + @name
module.exports.meeting = (req, res, next) ->
talker = new Talker 'Bob'
talker.talk()