为什么这个对象的属性没有定义?Javascript
属性是以下形式的对象:为什么这个对象的属性没有定义?Javascript,javascript,Javascript,属性是以下形式的对象: var attribute = { AttributeId: attributeId, EntityId: entityId, AttributeDBName: attributeDbName, AttributeDisplayName: attributeDisplayName, IsSearchable: isSearchable, IsDeleted: isDeleted, IsVisible: isVi
var attribute = {
AttributeId: attributeId,
EntityId: entityId,
AttributeDBName: attributeDbName,
AttributeDisplayName: attributeDisplayName,
IsSearchable: isSearchable,
IsDeleted: isDeleted,
IsVisible: isVisible,
AttributeTypeId: attributeTypeId,
Description: description,
IsSystem: isSystem,
IsActive: isActive,
IsUnique: isUnique,
IsRequired: isRequired,
IsPersistent: isPersistent,
DefaultValue: defaultValue
};
然后将该属性与网格ID一起传递到此函数:
function AddAttributeToGrid(attribute, gridId) {
console.log(attribute); //Works! Displays the attribute.
var id = a.attributeId;
console.log(id);//UNDEFINED? WHAT?
}
如果我创建一个全局变量(我们称之为“tempAttribute”),并将其设置在AddAttributeToGrid中,如下所示:
function AddAttributeToGrid(attribute, gridId) {
tempAttribute = attribute
}
然后我可以访问tempAttribute的属性
为什么我不能从属性中获取数据?
发生了什么事?我想你已经知道了
var id = a.attributeId;
而不是
var id = attribute.AttributeId;
在AddAttributeToGrid
函数定义中,我想您已经
var id = a.attributeId;
而不是
var id = attribute.AttributeId;
在
AddAttributeToGrid
函数定义中属性的属性是AttributeId
,而不是AttributeId
JavaScript区分大小写
但这假设您首先使用定义的attributeId
初始化了对象。这在代码中不清楚。属性的属性是AttributeId
,而不是AttributeId
JavaScript区分大小写
但这假设您首先使用定义的attributeId
初始化了对象。这在您的代码中不清楚。Omg。我不敢相信我错过了。。。LMFAO!谢谢:)天哪。我不敢相信我错过了。。。LMFAO!谢谢:)结束:)原来那只是一封该死的国会信件,而不是小写!Close:)原来那只是一封该死的国会大厦的信,而不是小写的!