I'm migrating a project from CoffeeScript to ES6 (using 6to5 and Browserify), and am running into possibly a limitation or maybe I just don't know the proper syntax. In CoffeeScript I could do this:
class SomeView extends BaseView
triggerMethod: Marionette.triggerMethod
How do I express this in ES6 classes? I tried a couple of things, but it throws Unexpected token
errors no matter what I try. This for example:
let { triggerMethod } = Marionette;
class SomeView extends BaseView {
triggerMethod, // doesn't work
triggerMethod: Marionette.triggerMethod // doesn't work
}
Now I can achieve this by setting it in the constructor (this.triggerMethod = Marionette.triggerMethod
), but it feels a bit ugly to me (just a preference in coding style I guess). Any help would be appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…