vue动态加载本地背景图(v-for循环背景图)

在这里插入图片描述

  1. 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>
  1. 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"
        }
      }]
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值