本文介绍了Vue 2 - Uncaught TypeError:cloned [i] .apply不是HTMLInputElement.invoker中的函数(vue.esm.js?65d7:1810)错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从标题中收到错误:
Uncaught TypeError: cloned[i].apply is not a function
at HTMLInputElement.invoker (vue.esm.js?65d7:1810)
标准设置使用 vue-cli(简单的webpack),这是我的组件:
Made standard setup with vue-cli (simple webpack), and this is my component:
<template>
<div class="column is-4">
<nav class="panel">
<p class="panel-heading">
Authors in our library
</p>
<div class="panel-block">
<p class="control has-icons-left">
<input class="input is-small" type="text" placeholder="Search"
v-model="search"
@keyup="filterAuthors">
<span class="icon is-small is-left">
<i class="fa fa-search"></i>
</span>
</p>
</div>
<a class="panel-block is-active" v-for="author in filterAuthors">
<span class="panel-icon">
<i class="fa fa-book"></i>
</span>
{{ author }}
</a>
</nav>
</div>
</template>
<script>
export default {
data () {
return {
'search' : ''
}
},
computed: {
filterAuthors() {
let search = this.search.toLowerCase();
return this.$store.state.authors.filter((author) => {
return author.toLowerCase().indexOf(search) >= 0;
})
}
}
}
</script>
奇怪的是过滤器正在工作,但每次输入输入字段时,我都会得到这个错误。任何人都知道它可以是什么?
Strange part is that the filter is working, but every time I type into the input field, I get this error. Anyone have any idea what can it be?
推荐答案
默认情况下,计算的属性是被动的,实际上你不能附加它们到事件处理程序。
Computed properies are reactive by default, and in fact you can't attach them to event handler.
删除调用计算属性的keyup事件处理程序应解决问题。
Removing the keyup event handler that calls computed property should fix the problem.
<p class="control has-icons-left">
<input class="input is-small" type="text" placeholder="Search">
<span class="icon is-small is-left">
<i class="fa fa-search"></i>
</span>
</p>
这篇关于Vue 2 - Uncaught TypeError:cloned [i] .apply不是HTMLInputElement.invoker中的函数(vue.esm.js?65d7:1810)错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!