ここに基本クラスがあります:
function Screen(src) {
this.src = src;
}
Screen.prototype.html = function(collapsed) {
return $.ajax({
async : false,
url : this.src + "?collapsed=" + collapsed,
}).responseText;
};
そして、私はそれをサブクラス化しようとします:
function TitleScreen() {
Screen.call(this, "title.php");
};
TitleScreen.prototype = Object.create(Screen.prototype);
TitleScreen.prototype.constructor = TitleScreen;
TitleScreen.prototype.parent = Screen.prototype;
ただし、そうして TitleScreen オブジェクトを使用しようとすると、src プロパティが設定されていますが、html 関数が定義されていません! また、次のように、コンストラクターで html 関数を設定しようとしました。
function Screen(src) {
this.src = src;
this.html = function(collapsed) {
return $.ajax({
async : false,
url : this.src + "?collapsed=" + collapsed,
}).responseText;
};
}
しかし、それもうまくいきませんでした。普通の古い属性は機能するが機能は機能しない可能性がある、私は何を間違っていますか?