VueJS-事件&单击&无效的处理程序:未定义 [英] VueJS - Invalid handler for event "click": got undefined

查看:17
本文介绍了VueJS-事件&单击&无效的处理程序:未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一系列元素,我想在单击它们时进行编辑。 我在其他组件中有类似的解决方案,它工作得很好,但在新的组件中却不是,也找不到原因。

呈现组件时,我得到: Invalid handler for event "click": got undefined

列表:

<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)
      },
当我只需单击时,我在EDIT SNF div中收到通知,并显示表单,我可以使用SAVE(AJAX)、Cancel(只需将Inedit设置为空)等,但只要我触摸EDIT div中的任何输入,我就会得到: [Vue warn]: Invalid handler for event "click": got undefined vue.common.js?e881:1559 Uncaught (in promise) TypeError: Cannot read property 'invoker' of undefined 一旦我收到错误,编辑中的任何按钮都不起作用。

相同的div用于新建/编辑,并且完全适用于新的公告。 有什么想法吗?

整个组件粘贴:http://pastebin.com/JvkGdW6H

推荐答案

收到。它不是关于顶层功能@click。 当调用顶层单击时,将呈现的元素大约为@click。我的函数名有一个拼写错误。 不幸的是,Vue没有抛出丢失的函数的名称,这就是我找不到它的原因,因为我找错了地方...

这篇关于VueJS-事件&单击&无效的处理程序:未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆