2

i have this Vue component but i don't understand the problem :

<template>
    <div>
        <div class="all-cards" >
            <template v-for="(card,index) in res" >
                <div class="cards-new "  draggable="true" :data-id="card.id" @click="infoCard(index)" :key="card.id">
                    <div class="image-card"></div>
                    <div class="titles-card"> 
                        <p>{{card.title}}</p>
                    </div>
                    <div class="footer-card">
                        <div class="circle-people-card"></div>
                    </div>
                </div>
            </template>    
        </div>
        <card-info descriptionCard="hi" idInfo="2" titleCard="sua"></card-info>
    </div>
</template>

<script>
import axios from 'axios';
import CardInfo from './CardInfo.vue'
export default {
  name: 'Card',  
  components:{
      CardInfo
  },
  data(){
      return{
        uri : 'http://localhost:8000',
        res: [],   
        infoCard:'' 
    }
  },
  methods:{
      infoCard: function(clickedId){
          return this.infoCard = clickedId;
      }
  },
  mounted(){
      let url = this.uri + "/ajax/field-info"
      axios.get(url).then((msg) => {
           this.res = msg.data
      });
  }
}
</script>

<style>

</style>

Continue to return me this error:

TypeError: t.infoCard is not a function at click (app.f815278e.js:1) at Xe (900.23d000da.js:2) at HTMLDivElement.n (900.23d000da.js:2) at HTMLDivElement.o._wrapper (900.23d000da.js:2)

Can anyone help me ?

1

1 Answer 1

3

You can not have same name infoCard for data property and method, change one and then try.

Sign up to request clarification or add additional context in comments.

4 Comments

Agree on your comment ... what is your answer?
You could change the data property name from infoCard to something else
Is right , thank you man
You are welcome mate, cheers :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.