0
<template>
   
    <form class="questionnaire-result" action="#">
        <h1 class="h1">Here are your result!</h1>
        <div class="grid-container">
            <h2 class="sub-club"> Sub-Club</h2>
            <h2 class="score"> Score</h2>
            <h2 class="join-que"> Want to Join?</h2>
            <div class="sub-club-section " v-for="(subclub) in subclubs" :key="subclub.id">
                    <div class="responsive">
                        <div class="gallery">
                            <img class="image" :src="subclub.path">
                            <div class="desc">{{subclub.name}}</div>
                        </div>
                        </div>
                    <h3 v-if="subclub.score>50" class="score-result" style="color:#0cf12a ">{{subclub.score}}%</h3>
                    <h3 v-else class="score-result" style="color:red ">{{subclub.score}}%</h3>
                    <div v-if="subclub.score>50">
                        <input class="join-btn option-input " type="checkbox" v-bind:value="subclub.name"  v-model="selected_subclubs" >
                    </div>
            </div>
     {{selected_subclubs}}
        <button @click=" goToHomePage()" class="button "><span> JOIN </span></button>
      
        </div>
    </form>

    </div>
  
</template>

<script>
export default {
    name:"QuestionnaireResult",
    data(){
      
        return{
            selected_subclubs:[],
            subclubs:[
             { 
                id:1,
                name:"Yoga",
                score:70,
                path:"@/assets/sub-clubs-images/Yoga_mini.jpeg",
              
                
            },
            
            ]
        }
    },
    methods:{
            goToHomePage(){
                this.$router.push("/");
            }
    }
}
</script>

I apply it like this , I put the path in the data to company src. It worked this way for many people. but I cannot put the image on the page . It works when I pass the path directly to the src as a string.I can't understand how I can't get the path.Can you help me.

I tried to do it like this: Vue.js image v-for bind

ND.
  • 3
  • 3
  • Please do not work with pictures it makes it harder to reproduce because we can't copy and paste – Seppe Mariën May 21 '21 at 23:44
  • @SeppeMariën sorry , edited – ND. May 22 '21 at 00:01
  • 1
    Does this answer your question? [Passing and binding img src from props in Vue.js](https://stackoverflow.com/questions/56624817/passing-and-binding-img-src-from-props-in-vue-js) – dyslexit May 25 '21 at 00:59

1 Answers1

0

You need to import the image from webpack using require to pass it using javascript

See these other posts for more details

How to bind img src to data in Vue

Passing and binding img src from props in Vue.js

dyslexit
  • 689
  • 1
  • 9
  • 18