简体   繁体   中英

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:

<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

在此处输入图像描述

have you tried using an image tag? Like <img:src="item.image" alt="none" /> . and have your image in data as just a string like "../assets/img1.jpg" .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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