【发布时间】:2015-11-27 02:03:34
【问题描述】:
有
upperclass = class Superclass
constructor: () ->
@somemethod: () ->
console.log "I'm in super"
@someothermethod: () ->
console.log "I'm trying to reach super without going through sub!"
@somemethod()
lowerclass = class Subclass extends Superclass
constructor: () ->
@somemethod: () ->
console.log "I'm in sub but only want to go to super! I.e. not through sub, calling super here!"
@someothermethod: () ->
super
lowerclass.someothermethod()
我希望@somemethod 调用直接转到超级方法,避免使用子方法。那可能吗?在某些方法声明中添加了@,以使其与 CoffeeScript 测试器 here 一起使用。
【问题讨论】:
标签: javascript class oop inheritance coffeescript