我有3 * 3的网格,并且我有一个滑块,可以根据所选项目在单击时更改图像。我为每个项目及其图像制作了一个对象,如下所示:
const projects = {
cancellato: [
'assets/media/images/cancellato/cancellato-01.jpg',
'assets/media/images/cancellato/cancellato-02.jpg',
'assets/media/images/cancellato/cancellato-03.jpg',
'assets/media/images/cancellato/cancellato-04.jpg',
'assets/media/images/cancellato/cancellato-05.jpg',
'assets/media/images/cancellato/cancellato-06.jpg',
'assets/media/images/cancellato/cancellato-07.jpg',
'assets/media/images/cancellato/cancellato-08.jpg',
'assets/media/images/cancellato/cancellato-09.jpg'
],
artsupply: [
'assets/media/images/artsupply/artsupply-01.jpg',
'assets/media/images/artsupply/artsupply-02.jpg',
'assets/media/images/artsupply/artsupply-03.jpg',
'assets/media/images/artsupply/artsupply-04.jpg',
'assets/media/images/artsupply/artsupply-05.jpg',
'assets/media/images/artsupply/artsupply-06.jpg',
'assets/media/images/artsupply/artsupply-07.jpg',
'assets/media/images/artsupply/artsupply-08.jpg',
'assets/media/images/artsupply/artsupply-09.jpg'
],
bcefw: [
'assets/media/images/bcefw/bcefw-01.jpg',
'assets/media/images/bcefw/bcefw-02.jpg',
'assets/media/images/bcefw/bcefw-03.jpg',
'assets/media/images/bcefw/bcefw-04.jpg',
'assets/media/images/bcefw/bcefw-05.jpg',
'assets/media/images/bcefw/bcefw-06.jpg',
'assets/media/images/bcefw/bcefw-07.jpg',
'assets/media/images/bcefw/bcefw-08.jpg',
'assets/media/images/bcefw/bcefw-09.jpg'
]
}
现在我要做的就是将图像的源更改为对象内部任何数组的源,
将两个div堆叠在一起并更改显示是更好的做法吗?