Ich habe eine debounce Nutzenfunktion:Warum bricht diese Entprellfunktion "dieses"?
debounce (func, wait, immediate) {
let timeout
return function() {
const context = this
const args = arguments
const later = function() {
timeout = null
if (!immediate) func.apply(context, args)
}
const callNow = immediate && !timeout
clearTimeout(timeout)
timeout = setTimeout(later, wait)
if (callNow) func.apply(context, args)
}
}
Was ich wie folgt verwenden:
updateField: utils.debounce((event, fieldName, schema) => {
const value = event.target.value
this.$emit('updateField', fieldName, value, schema)
validateFields(this)
}, 500),
Die Entprellfunktion funktioniert. Allerdings bekomme ich diesen Fehler:
Uncaught TypeError: _this.$emit is not a function
Was könnte das Problem sein?