用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()执行?
return this.init()
因为你确实没有定义
then
方法,而且不知道你为什么要这样。。