我正在尝试在动态生成的子标题 v-list-tile Vuetify 上绑定点击事件https://vuetifyjs.com/en/components/subheaders但每次我单击该选项时都会出现错误。
vue.js:634 [Vue warn]: Error in v-on handler: "TypeError: handler.apply is not a function"
found in
---> <VListTile>
<VList>
<VCard>
<VApp>
<Root>
我尝试强制添加方法(不传递对象)并且它有效。它只是在传递给对象并动态渲染时触发。
这是我遇到的错误的Codepen。
我期望的是触发被调用的方法而不触发错误
在我的例子中,我正在侦听从子组件发出的事件,并且对接收到的值不执行任何操作:
<my-component @hide="show" v-if="show"/>
我应该在收到值时更改该值:
<my-component @hide="show = $event" v-if="show"/>
我希望它对某人有帮助。
这发生在我身上,因为我在 HTML 标签上编写了类似的代码:
@something="colorList"
其中
colorList
是一个 javascript 对象数组。相反,您必须编写一个将值传递到的函数,并在函数内设置该值:
<... @something="updateColorList" ...>
并且在
methods
updateColorList(newColorParameter): {
this.colorList = newColorParameter
}
我收到此错误是因为我定义了同名的变量和方法。
<script>
data: {
toggleSideBar: flase,
},
methods: {
toggleSideBar() {
this.toggleSideBar = !this.toggleSideBar;
},
}
</script>
解决方案: 我更改了方法的名称,以便它与变量不同。