<p>&quot;<template>\n  <div>\n    &lt;van-image\n      v-for=&quot;(image, index) in images&quot;\n      :key=&quot;index&quot;\n      v-bind:src=&quot;image.url&quot;\n      fit=&quot;cover&quot;\n      :width=&quot;100&quot;\n      :height=&quot;100&quot;\n      @click=&quot;showImage(index)&quot;\n    /&gt;\n    <van-popup v-model="showPopup" position="center">\n      &lt;van-image\n        v-bind:src=&quot;selectedImage.url&quot;\n        fit=&quot;contain&quot;\n        :width=&quot;300&quot;\n        :height=&quot;300&quot;\n        @click=&quot;closePopup&quot;\n      /&gt;\n    </van-popup>\n  </div>\n</template>\n\n<script>\n export default {\n  data() {\n    return {\n      images: [\n        { url: 'https://example.com/image1.jpg' },\n        { url: 'https://example.com/image2.jpg' },\n        { url: 'https://example.com/image3.jpg' },\n      ],\n      showPopup: false,\n      selectedImage: null,\n    };\n  },\n  methods: {\n    showImage(index) {\n      this.selectedImage = this.images[index];\n      this.showPopup = true;\n    },\n    closePopup() {\n      this.showPopup = false;\n    },\n  },\n};\n</script>&quot;\n在上述示例中,我们使用了<code>van-image</code>组件来展示图片,并且通过<code>v-for</code>指令循环渲染数据库中的图片地址。当用户点击图片时,会调用<code>showImage</code>方法来显示被点击的图片。我们使用<code>van-popup</code>组件来实现图片放大查看的弹窗效果,并且在弹窗中使用<code>van-image</code>组件展示被点击的图片。用户可以通过点击弹窗中的图片来关闭弹窗,实现放大查看的效果。</p>

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

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