为什么我看不到问题?有人可以帮我吗? 我知道这是个很愚蠢的问题..但我没有看到它..未捕获ReferenceError xxx未定义
执行:var xxx = new User()
,我总是得到这样的:
ready!
VM1507:1 Uncaught ReferenceError: User is not defined(…)
对不起问..
$(function() {
console.log("ready!");
function User() {
this.badgeVervalDatum = null;
this.bijNaam = null;
this.contactVia = null;
this.email = null;
this.familieNaam = null;
this.gsm = null;
this.id = null;
this.middleNaam = null;
this.postcode = null;
this.rkNummer = null;
this.sanBekw = null;
this.straat = null;
this.voorNaam = null;
this.volledigNaam = null;
this.woonplaats = null;
this.timeCreated = 0;
this.timeUpdate = 0;
this.timeLastLogin = 0;
}
User.prototype = {
constructor: User,
addEmail: function(email) {
this.email = email;
return true;
}
}
});
函数'User()'被定义在内*即“ready”处理程序中,所以它只能从该上下文中调用。它不是全球可用的。你想在哪里调用函数? – Pointy
请注意,User只在被调用的匿名函数内定义,即$(function(){function User(){....}});新的用户()'不起作用 –
哦,yeeess !!!! omg我好蠢! –