在一个_changes/data.js
文件中,我有以下实现:
function(data) {
var p;
var tmp = $$("#profile");
$.log(tmp);
$.log(tmp.profile);
if (undefined != tmp.profile) {
return {
cdrs : data.rows.map(function(r) {
p = r.value;
return p;
}),
message : "You are logged in as " + tmp.profile.name,
}
} else {
return {
cdrs : [ ] ,
message : "You are not logged in",
}
}
};
我很困惑,因为在重新加载应用程序后,立即$.log(tmp.profile);
显示“未定义”,即使前面$.log(tmp);
清楚地表明 javascript 对象确实有一个名为profile
(类型Object
为预期数据)的成员。
更奇怪的是:当更改通知启动时,$.log(tmp.profile);
显示的是正确的数据,即使$.log(tmp);
没有显示任何更改。
到底是怎么回事?我在这里缺少任何封装规则吗?