javascript对象问题
我试图理解别人的密码。他有javascript对象问题,javascript,object,Javascript,Object,我试图理解别人的密码。他有 task.prototype.taskAttributes = { 'header' : [ {'name' : 'display_type', 'display' : 'Display Type', 'type' : 'select', 'options' : { 'default' : 'Default', name1 : 'Peter', name2 : 'Ted', } }, {'nam
task.prototype.taskAttributes = {
'header' : [
{'name' : 'display_type', 'display' : 'Display Type', 'type' : 'select', 'options' : {
'default' : 'Default',
name1 : 'Peter',
name2 : 'Ted',
}
},
{'name' : 'background', 'display' : 'Background', 'type' : 'image'},
{'name' : 'background_position', 'display' : 'Background Position', 'type' : 'text'},
{'name' : 'credit', 'display' : 'Background Credit', 'type' : 'text'}],
'input' : [
{'name' : 'display_type', 'display' : 'Display Type', 'type' : 'select', 'options' : {
'default' : 'Default',
title1 : 'manager',
title2 : 'employee'}
},
{'name' : 'background', 'display' : 'Background', 'type' : 'image'},
{'name' : 'background_position', 'display' : 'Background Position', 'type' : 'text'},
'image' : [{'name' : 'column', 'type' : 'select', 'options' : ['', 'left', 'right']}]
}
我不确定“标题
”和“输入
”是否是对象属性?
“标题”和“输入”下的属性是什么
这些功能是什么:
{'name' : 'display_type', 'display' : 'Display Type', 'type' : 'select', 'options' : {
'default' : 'Default',
name1 : 'Peter',
name2 : 'Ted',
}
},
{'name' : 'background', 'display' : 'Background', 'type' : 'image'},
{'name' : 'background_position', 'display' : 'Background Position', 'type' : 'text'},
{'name' : 'credit', 'display' : 'Background Credit', 'type' : 'text'}],
我想声明对象属性,我们是这样做的
attribute={header:'header', input:'input'}
我不知道他为什么有这么多的阿特崔布
谢谢你们的帮助 标题
和输入
确实是任务属性
的对象属性,以及图像
taskAttributes = {
// Three object properties, each is an array
header: [],
input: [],
image: []
}
其中每一个本身都是对象的数组[]
,具有名称
,显示
,类型
等属性。这解决了你问题中的“这些做什么”部分
// Example object element of the parent attribute arrays:
// There are multiples of these objects for each property header, input, image
{'name' : 'background', 'display' : 'Background', 'type' : 'image', 'options': {...}}
例如,要访问标题下的第一个名称
,您可以访问其数组键[0]
,如下所示:
taskAttributes.header[0].name
// 'displayType'
// And the third array element [2]
taskAttributes.header[2].name
// 'credit'
头
和输入
的第一个数组元素上还有一个嵌套级别,如下所示:
// Property named options is an object...
'options' : {
'default' : 'Default',
title1 : 'manager',
title2 : 'employee'
}
这是另一个对象,每个对象都引用为选项
taskAttribtues.header[0].options.title1
// 'manager'
标题
和输入
确实是任务属性
的对象属性,以及图像
taskAttributes = {
// Three object properties, each is an array
header: [],
input: [],
image: []
}
其中每一个本身都是对象的数组[]
,具有名称
,显示
,类型
等属性。这解决了你问题中的“这些做什么”部分
// Example object element of the parent attribute arrays:
// There are multiples of these objects for each property header, input, image
{'name' : 'background', 'display' : 'Background', 'type' : 'image', 'options': {...}}
例如,要访问标题下的第一个名称
,您可以访问其数组键[0]
,如下所示:
taskAttributes.header[0].name
// 'displayType'
// And the third array element [2]
taskAttributes.header[2].name
// 'credit'
头
和输入
的第一个数组元素上还有一个嵌套级别,如下所示:
// Property named options is an object...
'options' : {
'default' : 'Default',
title1 : 'manager',
title2 : 'employee'
}
这是另一个对象,每个对象都引用为选项
taskAttribtues.header[0].options.title1
// 'manager'
是,标题
、输入
和图像
是任务.prototype.taskAttributes
对象的属性,每个属性都包含一个对象数组。通过管道传递代码,可以通过缩进来强调文字结构:
task.prototype.taskAttributes = {
'header': [{
'name': 'display_type',
'display': 'Display Type',
'type': 'select',
'options': {
'default': 'Default',
'name1': 'Peter',
'name2': 'Ted',
}
}, {
'name': 'background',
'display': 'Background',
'type': 'image'
}, {
'name': 'background_position',
'display': 'Background Position',
'type': 'text'
}, {
'name': 'credit',
'display': 'Background Credit',
'type': 'text'
}],
'input': [{
'name': 'display_type',
'display': 'Display Type',
'type': 'select',
'options': {
'default': 'Default',
'title1': 'manager',
'title2': 'employee'
}
}, {
'name': 'background',
'display': 'Background',
'type': 'image'
}, {
'name': 'background_position',
'display': 'Background Position',
'type': 'text'
},
'image': [{
'name': 'column',
'type': 'select',
'options': ['', 'left', 'right']
}]
};
是,标题
、输入
和图像
是任务.prototype.taskAttributes
对象的属性,每个属性都包含一个对象数组。通过管道传递代码,可以通过缩进来强调文字结构:
task.prototype.taskAttributes = {
'header': [{
'name': 'display_type',
'display': 'Display Type',
'type': 'select',
'options': {
'default': 'Default',
'name1': 'Peter',
'name2': 'Ted',
}
}, {
'name': 'background',
'display': 'Background',
'type': 'image'
}, {
'name': 'background_position',
'display': 'Background Position',
'type': 'text'
}, {
'name': 'credit',
'display': 'Background Credit',
'type': 'text'
}],
'input': [{
'name': 'display_type',
'display': 'Display Type',
'type': 'select',
'options': {
'default': 'Default',
'title1': 'manager',
'title2': 'employee'
}
}, {
'name': 'background',
'display': 'Background',
'type': 'image'
}, {
'name': 'background_position',
'display': 'Background Position',
'type': 'text'
},
'image': [{
'name': 'column',
'type': 'select',
'options': ['', 'left', 'right']
}]
};
对象(和数组)可以嵌套任意数量的级别。JSON修饰符可能有助于理解结构。标题
、输入
和图像
是对象数组(请注意方括号:[
和]
)。对象(和数组)可以嵌套任意级别。JSON修饰符可能有助于理解结构。标题
、输入
和图像
是对象数组(请注意方括号:[
和]
)。