1
我使用Javascript,我想創建授權類。Javascript函數實例和調用
我的代碼是
function Auth() {
this.action;
this.run = function() {
$("#auth-dialog-id").dialog({
width: 400,
height: 250,
modal: true,
buttons: {
OK: function() {
this.action();
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
}
});
};
}
呼叫
auth = new Auth();
auth.action = a;
auth.run();
}
function a() {
alert("test");
}
,但我有錯誤
對象#有沒有方法 '動作'
任何人可以幫助我嗎?
嘗試用'auth.action'代替'this.action =一個;' –
供參考: 'this.action;'實際上什麼都不做。它的目的是作爲文檔嗎? –
我很抱歉。我已更正了我的問題 – javagc