利用for循环和flex布局同时做多个样式大致相同内容不同的div盒子,:style=“`background: url(${item.img})`“添加盒子的不同背景图片
实现目标:采用for循环取数组中的数据,结合flex布局生成多个盒子,减少代码冗余。实现效果:实现方法:1.template中:这里涉及到图片的添加,直接采用img标签,以及背景图片的添加,是采用:style="`background: url(${item.img})`"的形式。<div class="box"> <div class="box-content" v-for="(item, index) in statistic" :key="index" :