【发布时间】:2017-04-04 04:04:31
【问题描述】:
我有点击后想要编辑的元素列表。 我在其他组件中有类似的解决方案,它工作得很好,但在新的组件中却没有,也找不到原因。
当组件被渲染时,我得到:
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)
},
当我单击时,我在编辑 snf div 中显示了带有表单的公告,我可以使用保存(ajax)、取消(只需将 inedit 设置为 null)等,但只要我触摸编辑 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 用于新建/编辑,并且在新建公告时工作得非常好。 有什么想法吗?
整个组件pastebin:http://pastebin.com/JvkGdW6H
【问题讨论】:
-
可能是一些小错误,最好把整个组件结构贴出来。
标签: javascript vue.js single-page-application