question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Vue warn]: Invalid handler for event "click": got undefined / vue.common.js?e881:1559 Uncaught (in promise) TypeError: Cannot read property 'invoker'

See original GitHub issue

Vue.js version

2.0.8

Steps to reproduce

Do the same?

What is Expected?

Working…

What is actually happening?

Hi,

I have list of elements which I want to go to edit when clicked. I have similar solution in other component and it is working perfectly fine but in new one it is not and can’t find why.

When component is rendered I got: Invalid handler for event "click": got undefined

List:

<div v-for="annt in anns" class="item two-lines" v-if="!anntInEdit">
          <div class="item-content has-secondary" v-on:click="edit(annt)">
            <div>
              {{ annt.title }}
            </div>
            <div >
              {{ annt.body}}
            </div>
          </div>
          <div class="item-secondary">
          <a><i >delete</i></a>
          </div>
        </div>

JS:

edit (annt) {
        if (this.anntInEdit == null) {
          this.anntInEdit = annt
          this.anntInEditBackup = Object.assign({}, this.anntInEdit)
        }
        this.anntInEditIndex = this.anns.indexOf(annt)
      },

When I will just click, I got Announcement in edit snf div with form is shown, I can use save(ajax), cancel (just set inedit to null) etc. but as soon as I touch any input inside edit div I got: [Vue warn]: Invalid handler for event "click": got undefined vue.common.js?e881:1559 Uncaught (in promise) TypeError: Cannot read property 'invoker' of undefined and as soon as I get errors, any button in edition is not working at all.

Full error stack:

warn	@	vue.common.js?e881:2658
updateListeners	@	vue.common.js?e881:1527
updateDOMListeners	@	vue.common.js?e881:4553
invokeCreateHooks	@	vue.common.js?e881:3951
createElm	@	vue.common.js?e881:3922
updateChildren	@	vue.common.js?e881:4097
patchVnode	@	vue.common.js?e881:4159
updateChildren	@	vue.common.js?e881:4084
patchVnode	@	vue.common.js?e881:4159
updateChildren	@	vue.common.js?e881:4076
patchVnode	@	vue.common.js?e881:4159
patch	@	vue.common.js?e881:4272
Vue._update	@	vue.common.js?e881:1734
(anonymous function)	@	vue.common.js?e881:1707
get	@	vue.common.js?e881:736
run	@	vue.common.js?e881:805
flushSchedulerQueue	@	vue.common.js?e881:623
nextTickHandler	@	vue.common.js?e881:401
```

The same div is used for new/edit and is working perfectly fine for new annoucement.
Any ideas? I don't think there is any error in my code as I really have exactly the same logic in another component and it is working perfectly fine.
Whole JS/HTML are inside the same Vue file.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

19reactions
Dafrokcommented, Aug 19, 2017

If you define a member of data or props as the same name with your handler, it will be broken.

For example, clicking that FOO button causes an error with the message: Invalid handler for event "click": got null

<template>
<div @click="edit">FOO</div>
</template>

<script>
export default {
  data () {
    return {edit: null}
  },
  methods: {
    edit () { /* do something */ }
  }
}
</script>
6reactions
Soumit-the-billionairecommented, Aug 11, 2018

check whether you have written method or methods ???

Read more comments on GitHub >

github_iconTop Results From Across the Web

VueJS - Invalid handler for event "click": got undefined
common.js?e881:1559 Uncaught (in promise) TypeError: Cannot read property 'invoker' of undefined and as soon as I get errors, any ...
Read more >
Invalid handler for event "click": got undefined - Vue Forum
[Vue warn]: Invalid handler for event "click": got undefined vue.common.js?e881:1559 Uncaught (in promise) TypeError: Cannot read property ...
Read more >
VueJS - Invalid handler for event "click": got undefined-Vue.js
Problem got resolved after the function got moved as a method rather than computed. This is not an answer but just updating my...
Read more >
VueJS – Invalid handler for event “click”: got undefined
[Vue warn]: Invalid handler for event "click": got undefined vue.common.js?e881:1559 Uncaught (in promise) TypeError: Cannot read property 'invoker' of ...
Read more >
vue.esm.js?efeb:628 [Vue warn]: Invalid handler for event “click“
vue.esm.js?efeb:628 [Vue warn]: Invalid handler for event "click": got undefined问题:解决原因问题:解决1.首先查看方法是否写在methods里2.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found