Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么这个对象的属性没有定义?Javascript_Javascript - Fatal编程技术网

为什么这个对象的属性没有定义?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:)原来那只是一封该死的国会大厦的信,而不是小写的!