在 Vue 中显示图片可以使用 img 标签,其 src 属性可以绑定一个图片的 URL 地址,例如:

<template>
  <div>
    <img :src="imageUrl" alt="图片">
  </div>
</template>

<script>
export default {
  data() {
    return {
      imageUrl: 'https://example.com/image.jpg'
    }
  }
}
</script>

当然,也可以使用 background-image 样式来显示图片,例如:

<template>
  <div :style="{ backgroundImage: 'url(' + imageUrl + ')' }"></div>
</template>

<script>
export default {
  data() {
    return {
      imageUrl: 'https://example.com/image.jpg'
    }
  }
}
</script>
``
vue中显示图片

原文地址: https://www.cveoy.top/t/topic/huSf 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录