我想通过使用 mixins 来拆分一个大类。
@include: (obj) ->
for key, value of obj when key not in moduleKeywords
# Assign properties to the prototype
@::[key] = value
obj.included?.apply(@)
this
class FooMixin
b: => @something = 2
class Foo extends Module
@include FooMixin
a: => @something = 1
问题是@in FooMixinis FooMixin。我希望它是Foo。
我尝试_.bind(@::[key], @)在末尾添加该行,@include()但没有帮助。有什么建议么?