Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

188
Visualizações
Property 'myfunc' was accessed during render but is not defined on instance

I don't know why but this error Property 'myfunc' was accessed during render but is not defined on instance is keeps on showing. I am sharing my Html and js code.

const ListRenderingApp = {
  data() {
    return {
      todos: [
        { text: 'Learn JavaScript' },
        { text: 'Learn Vue' },
        { text: 'Build something awesome' }
      ]
    }
  },
  method : {
    myfunc(){
      console.log('drats')
    }
  }
}
Vue.createApp(ListRenderingApp).mount('#list-rendering')

And the Html files code is

<div id="list-rendering" class="demo">
  <ol>
    <li v-for="todo in todos">
      {{ todo.text }}
    </li>
    
  </ol>
  <button v-on:click="myfunc"> Click me</button>
</div>

I am very new to Vue.js. So, if anyone can please help me with this question.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I understood the error. And came up with the solution as well.

Firstly, In the ListRenderingApp after the data function. It should be methods. And secondly, in the console.log() statement it should be console.log(this.todos).

about 4 years ago · Juan Pablo Isaza Relatório

0

Working Demo :

new Vue({
  el: '#app',
  data: {
    todos: [
        { text: 'Learn JavaScript' },
        { text: 'Learn Vue' },
        { text: 'Build something awesome' }
      ]
  },
  methods : {
    myfunc() {
      console.log('drats')
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

<div id="app">
  <ol>
    <li v-for="todo in todos">
      {{ todo.text }}
    </li>
  </ol>
  <button v-on:click="myfunc"> Click me</button>
</div>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda