0
我在coffeescript faq中发现了这个mixin的例子,但它似乎不起作用。CoffeeScript mixin不起作用
我在这里错过了什么吗?
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'