简体   繁体   English

Vue.js。 我的方法中的 function 无法识别

[英]Vue js . my function in methods isn't recognized

i have this Vue component but i don't understand the problem:我有这个 Vue 组件,但我不明白这个问题:

<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) TypeError: t.infoCard 不是 function 在 HTMLDivElement.o._wrapper (900.23) 的 Xe (900.23d000da.js:2) 上的点击 (app.f815278e.js:1) d000da.js:2)

Can anyone help me?谁能帮我?

You can not have same name infoCard for data property and method, change one and then try.数据属性和方法不能有同名的infoCard ,换一个再试试。

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

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