![在这里插入图片描述](https://img-blog.csdnimg.cn/14cf7b84205e4e6188ca9e197ffbccf7.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MTU2NTQ3Nw==,size_16,color_FFFFFF,t_70#pic_center)
- template中 :style="item.imageUrl
<div class="resources-box" v-for="item in aginList" :key="item.id" :style="item.imageUrl">
<div>
<CountTo class="number" :startVal='0' :endVal='item.value' :duration='1000'></CountTo>
</div>
<div class="box-txt">{{item.name}}</div>
</div>
- data中数据结构
aginList:[{
id: 1,
name: '长者饭堂',
value: 26,
color: '#2268E4',
imageUrl: {
backgroundImage:
"url(" + require("../../assets/endowment/fantang.png") + ")",
backgroundRepeat: "no-repeat",
backgroundSize: "cotain"
}
},{
id: 2,
name: '长者服务站',
value: 2644,
color: '#19A7EF',
imageUrl: {
backgroundImage:
"url(" + require("../../assets/endowment/zzfuwu.png") + ")",
backgroundRepeat: "no-repeat",
backgroundSize: "cotain"
}
},{
id: 3,
name: '长者服务中心',
value: 3454,
color: '#2DBF92',
imageUrl: {
backgroundImage:
"url(" + require("../../assets/endowment/zhangzhe.png") + ")",
backgroundRepeat: "no-repeat",
backgroundSize: "cotain"
}
},{
id: 4,
name: '社区综合服务中心',
value: 789,
color: '#C8C71D',
imageUrl: {
backgroundImage:
"url(" + require("../../assets/endowment/zhonghe.png") + ")",
backgroundRepeat: "no-repeat",
backgroundSize: "cotain"
}
},{
id: 5,
name: '日间照料中心',
value: 26,
color: '#F29907',
imageUrl: {
backgroundImage:
"url(" + require("../../assets/endowment/rijian.png") + ")",
backgroundRepeat: "no-repeat",
backgroundSize: "cotain"
}
},{
id: 6,
name: '星光老年之家',
value: 26,
color: '#F37158',
imageUrl: {
backgroundImage:
"url(" + require("../../assets/endowment/zhangzhe.png") + ")",
backgroundRepeat: "no-repeat",
backgroundSize: "cotain"
}
}]