http://stackoverflow.com/questions/38807521/es6-class-promise-chain-accessing-this
module.exports = class Xxxxx {
start () {
let self = this
return this.before()
.then(this.renderLayout.bind(this))
.then(this.processError.bind(this))
}
renderLayout () {
let self = this
return self.compile(self.layout, self.data)
}
processError (err) {
console.log(err)
}
before() {
console.log('after')
}
after() {
console.log('after')
}
}
备忘一下
return this.before()
.then(this.renderLayout.bind(this))
.then(this.processError.bind(this))