我的输入如下。
<input
type="text"
maxlength="50"
v-on:input="query = $event.target.value"
v-on:keyup.enter="once(search)"
/>
有一种名为search and lodash的方法。
import _ from 'lodash'
methods:{
once(func){
return _.once(func)
},
async search(){
// An api call is in it
}
}
但是在这种情况下,它显示“搜索未定义”。
我该如何做好这种情况?
答案 0 :(得分:2)
在尝试将方法传递给函数而又需要数据元素时给出错误。
最好不要一次使用vue本身的事件处理程序https://vuejs.org/v2/guide/events.html#Event-Modifiers。
使用:
v-on:keyup.enter.once