gpt4 book ai didi

javascript - js es6类构造函数在构造函数实例化之前运行

转载 作者:搜寻专家 更新时间:2023-11-01 04:08:12 24 4
gpt4 key购买 nike

<分区>

我有一个 es6 类,它从函数调用中实例化一个变量,但问题是该函数似乎在构造函数实例化并抛出错误之前运行:

  constructor() {
this.userSelections = {
types : this.getTypes(),
providers: this.getProvider()
}
}

getProvider() {
// here its throw error that this.userSelections is undefined
var activeType = this.userSelections.types.some(( type ) => {
return type.active;
});

}

问题是什么,我该如何处理这种情况?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com