【发布时间】:2013-05-03 19:45:31
【问题描述】:
我在 coffeescript faq 中找到了这个 mixins 示例,但它似乎不起作用。
我错过了什么吗?
extend = (obj, mixin) ->
for name, method of mixin
obj[name] = method
include = (klass, mixin) ->
extend klass.prototype, mixin
class Button
onClick: -> alert "click"
class Events
include Button, Events
(new Events).onClick()
# => Uncaught TypeError: Object #<Events> has no method 'onClick'
【问题讨论】:
标签: coffeescript