Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
200 views
in Technique[技术] by (71.8m points)

vue.js - Image not loading in vue js

I am trying to reference an image to display in view but I can't get it right. This is the error I get "InvalidCharacterError: Failed to execute 'setAttribute' on 'Element': 'product.images[0].filename' is not a valid attribute name."

Please assist to reference an image in image2 path Here is my code:

 <div v-for="product in Products.data" :key="product.id" class="p-2">
             <div class="item p-2">{{product.id}}</div>
              <div class="item p-2">{{product.id}} Price:{{product.price}} </div>
              <div class="item p-2"><p>Loc:{{product.id}}</p></div>
                 <div class="item p-2"><p>fff:{{product.images[0].filename}}</p></div>

                 <img v-bind:src="'images2/'"+product.images[0].filename>
                 
             <div class="item p-2"> <a class="btn btn-primary btn-sm" :href="'/products/'+product.id">View</a>
             </div>
     
    </div> 

My problem is this line

                 <img v-bind:src="'images2/'"+product.images[0].filename>
question from:https://stackoverflow.com/questions/65948513/image-not-loading-in-vue-js

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
<img :src="'images2/'+product.images[0].filename"> 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...