2番目にconsole.log()実行されたによってWSFunctions[this.name]();印刷されますundentified。inherit DoThisAndThatどういうわけか自分の職務でできるのだろうかと思っていましたCall()。WSFunctions[this.name](this.params)プロジェクトが成長している間、渡す以上のものがあるかもしれないので、私は途中でパラメータを渡したくありませんでしたthis.params。
function WS(name, params) {
this.name = name;
this.params = params;
}
WS.prototype.Call = function() {
if (typeof WSFunctions[this.name] !== "function") {
return false;
}
console.log(this.params);
WSFunctions[this.name]();
return true;
}
var WSFunctions = {
'ScreenRightGuest': function() {
// .. whatever ..
return true;
},
'DoThisAndThat': function() {
console.log(this.params);
return true;
}
}
new WS('DoThisAndThat', { login: '123', pass: 'abc' }).Call();
よろしくお願いしますマイク