我想了解別人的代碼。他JavaScript對象問題
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']}]
}
我不知道如果「header
」和「input
」爲對象的屬性? 什麼條件下「header
」屬性和「input
」
做這些事:
{'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'}
,我不知道爲什麼他有這麼多的屁股。
感謝您的幫助!
對象(和數組)可以用任何數量的級別嵌套。 JSON美化器可能有助於理解結構。 – Bergi
'header','input'和'image'是對象數組(注意方括號:''''和']')。 – lbstr