简体   繁体   English

用 v-html 绑定图片

[英]Binding images with v-html

I have an array with some object and each object has an image tag, so i want to show this images but i dont know how i think the mistake is in the src of image.. Its my code in file in folder components its Template:我有一个包含一些 object 的数组,每个 object 都有一个图像标签,所以我想显示这些图像,但我不知道我如何认为错误出现在图像的 src 中。它是我在文件夹组件中的文件中的代码,它的模板:

<div v-for="(item, index) in items" :key="index">
 <div v-html="item.image"></div>
</div>

And its script及其脚本

data(){
 return {
  items: [
    {title : 'IMG1', image : '<img src="../assets/img1.jpg" alt="None">',},
    {title : 'IMG2', image : '<img src="../assets/img2.jpg" alt="None">',}
  ]
 }
}

But its just show None.. please how can i get this images?.但它只是显示无..请问我怎样才能得到这些图像? its my folder directory im in file posts.vue and i wanna get images in assets/images它是我的文件夹目录,我在文件 posts.vue 中,我想在 assets/images 中获取图像

在此处输入图像描述

have you tried using an image tag?您是否尝试过使用图像标签? Like <img:src="item.image" alt="none" /> .<img:src="item.image" alt="none" /> and have your image in data as just a string like "../assets/img1.jpg" .并将您的图像在数据中作为"../assets/img1.jpg"类的字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM