2
我有一个地图区域的对象。因为我也为所有其他领域使用主页区域。我想用一些东西将主页区域引用到所有其他区域,因此代码更具可读性和更短。 如何使用对象数组主页进行编辑?所以代码变得更短。像这样_images.edit.areas = _images.homepage.areas?或者我应该在一个单独的对象中定义主页?如何获取对象数组值到对象内的其他数组值?
var _images = {
homepage: {
path: 'homepage.jpg',
areas: [{
coords: '45,143,106,158',
text: 'edit',
goto: 'edit'
}, {
coords: '45,164,149,180',
text: 'config',
goto: 'config'
}, {
coords: '45,181,108,196',
text: 'setfree',
goto: 'setfree'
}]
},
edit:{
path: 'edit.jpg',
areas: [{
coords: '18,131,113,140',
text: 'homepage',
goto: 'homepage'
}, {
coords: '45,164,149,180',
text: 'config',
goto: 'config'
}, {
coords: '45,181,108,196',
text: 'setfree',
goto: 'setfree'
},{ //above everything is like in hompage, below are news areas
coords: '638,467,652,478',
text: 'contract',
goto: 'contract'
}]
},
}
好的,谢谢。那么,我会分开他们^^ – Emloy