1
私はデバウンスユーティリティ関数を作成:このデバウンス機能が「this」に壊れているのはなぜですか?
updateField: utils.debounce((event, fieldName, schema) => {
const value = event.target.value
this.$emit('updateField', fieldName, value, schema)
validateFields(this)
}, 500),
デバウンス機能が動作します。私はこのような使用
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)
}
}
を。しかし、私はこのエラーを受け取ります:
Uncaught TypeError: _this.$emit is not a function
何が問題なのですか?