实例:
var homePage={
isNewUser:function(){
var that = this;
$.ajax({
type: "GET",
url: "XXXX", //为接口
dataType: "jsonp",
success: function(data) {
if (typeof data == "object") {
console.log("ddsd",data);
if(data.XX==true){
// this.getNewUser(); 此时this无法访问homePage对象中getNewUser属性,因为此时this为jQuery中对象类的
that.getNewUser(); //that存储此时
}else{
}
}
}
});
},
getNewUser:function(){
//代码
},
init:function(){
this.isNewUser();//调用方法,this为homePage对象
}
}