Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
El método "getChampionName" tiene el tipo "indefinido" en la definición del componente. ¿Hiciste referencia a la función correctamente?

Estoy tratando de usar esta función (src/api/)

 function getChampionName(champId) { axios.get('http://ddragon.leagueoflegends.com/cdn/12.5.1/data/en_US/champion.json') .then(({ data }) => { let list = data let championList = list.data for (var i in championList) { if (championList[i].key == champId) { return championList[i].id } } }) .catch((err) => console.log(err)) } export {getChampionName}

En este componente (src/components/)

 <template> <div class="w-72"> <header class="rounded-tl-lg rounded-tr-lg bg-slate-400 p-0.5"> <p>Champion's Mastery</p> </header> <ul class="grid gap-1 rounded-bl-lg rounded-br-lg bg-slate-50 p-0.5"> <li v-for="champ in masteryData.slice(0,10)" :key="champ.championId"> <div class="flex items-center justify-between"> <div class="flex items-center gap-2"> <img src="https://ddragon.leagueoflegends.com/cdn/12.5.1/img/champion/Karma.png" alt="" class="rounded-lg h-14 w-14"> <div> <p class="font-medium text-center">{{ getChampionName(champ.championId) }}</p> <p>Level {{ champ.championLevel }}</p> </div> </div> <p class="text-2xl font-medium">{{ champ.championPoints }} Pts</p> </div> </li> </ul> </div> </template> <script> import getChampionName from '@/api/search' export default{ name: 'MasteryInfo', props: [ 'masteryData' ], methods: { getChampionName } } </script>

Pero recibo este error Method "getChampionName" has type "undefined" in the component definition. y no se que significa.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Parece que no importó el método correctamente. Cambie la importación a:

 import { getChampionName } from '@/api/search';

Puede leer más sobre importación y exportación en javascript aquí: https://javascript.info/import-export

Si cree que casi tiene la misma pregunta que esta pregunta, también puede consultar esto: El método "showDate" tiene el tipo "indefinido" en la definición del componente

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!