0
私のcreateCon関数はthisを使用してこのオブジェクトのconを設定します。私はこれを未定義にしています。エラー:未定義の 'con'のプロパティを設定できません。 これはオブジェクト関数からこれを参照できるのは何ですか?拡張子関数は 'this'を使用できません、キーワードは定義されていません
class parent {
constructor(stringA, stringB){
this.config = {};
this.con = {};
}
}
class child extends parent {
constructor(stringA, stringB) {
super(stringA,stringB)
this.config = {
full : stringA+stringB
}
}
createConn(){
var con = con(this.config.full);
con.connect(function(err){
if(!err) this.con = con;
})
}
}
@MikeMcCaughanこれは範囲の問題ではありません。それは拘束力のある問題です。 'this'の動作は変数スコープとは別に指定されます。 – slebetman