请帮助解决问题。我制作对象游戏:
Game = function(){
var self = this;
this.checkChecker = function(x_from, y_from){
console.log(2323);
};
this.start = function(){
$('#moveForm').on('submit', function(e){
e.preventDefault();
console.log(12121);
checkChecker(1,2);
});
}
}
我初始化了这个对象:
$(document).ready(function(){
game1 = new Game();
game1.start();
});
在控制台中单击#moveSubmit后显示: 12121
但我需要在控制台中显示
12121 2323
为什么函数this.checkChecker没有运行?
PS: 实例{{3}}
答案 0 :(得分:1)
小错误。 将checkChecker(1,2)更改为 self.checkChecker(1,2);
this.start = function(){
$('#moveForm').on('submit', function(e){
e.preventDefault();
console.log(12121);
self.checkChecker(1,2);
});
}