vue中img动态绑定src(网络图片https,http)

文章展示了如何在Vue项目中通过在index.html设置referrer策略,然后在组件中使用v-for循环动态绑定img标签的src属性,显示网络图片。图片源来自Gitee,并提供了包含多张图片的数据示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

vue访问网络图片

在index.html页面<head>标签中添加

<meta name="referrer" content="no-referrer">

vue中img动态绑定src(网络图片https)

vue绑定img图片资源

<el-row :gutter="20">
  <el-col :span="6"  v-for="item in imgList" :key="item.imgNo">
    <div class="grid-content bg-purple">
      <img :key="item.imgNo" draggable="false" :src="(`${item.src}`)" >
    </div>
  </el-col>
</el-row>

src地址

imgList:[
  {
    imgNo:1,
    src:'https://gitee.com/guo-xiaoya/images/raw/master/img/202304260905239.png',
    width:40,
    height:40
  },
  {
    imgNo:2,
    src:'https://gitee.com/guo-xiaoya/images/raw/master/img/202304260905239.png',
    width:40,
    height:40
  },
  {
    imgNo:3,
    src:'https://gitee.com/guo-xiaoya/images/raw/master/img/202304260905239.png',
    width:40,
    height:40
  },
  {
    imgNo:4,
    src:'https://gitee.com/guo-xiaoya/images/raw/master/img/202304260905239.png',
    width:40,
    height:40
  },
  {
    imgNo:5,
    src:'https://gitee.com/guo-xiaoya/images/raw/master/img/202304260905239.png',
    width:40,
    height:40
  }
],

效果

更多 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值