es6 class类封装方法疑问

用class封装一个方法:

const test=calss{constructor(){
..
this.init()
}
..init(){  
 //return new Promise( function (resolve, reject) {})}
}

init()放入了constructor,但是当去执行new test(a,b,c).then()会提示.then is not a function,必须constructor里移除this.init(),然后执行new test(a,b,c).init().then()才能正常执行,用什么方法怎样能让它这样new test(a,b,c).then()执行?


慕村225694
浏览 666回答 1
1回答

MM们

return this.init()因为你确实没有定义then方法,而且不知道你为什么要这样。。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript