Vue.js 引用错误 (event.target) 未定义

Vue.js reference error (event.target) not defined

我有一个具有不同方法的 vue 组件,f.ex。 mouseMove:

mouseMove: function(event) {
    console.log("Event is: " + event);
    element5 = event.target
    this.elementMove = element5
    if (element5.getAttribute('data') == 'day') {
        hourPreStart = parseInt(element5.getAttribute('value'))
        dayPreStart = parseInt(element5.parentElement.firstChild.getAttribute('day-value'));
        this.hourPreEnd = hourPreStart
        this.dayPreEnd = dayPreStart
    }
    console.log(this.hourPreStart, this.dayPreStart, this.hourPreEnd, this.dayPreEnd)
},

当我将鼠标悬停在某个字段上时出现此错误:

不知道是什么问题,因为定义了event

Here's 完整组件。 有人可以帮助我吗?

event5 未定义(如错误注视)。您必须先定义 event5 才能使用它。 使用这个

mouseMove: function(event) {
    console.log("Event is: " + event);
    let element5 = event.target
    this.elementMove = element5
    if (element5.getAttribute('data') == 'day') {
        let hourPreStart = parseInt(element5.getAttribute('value'))
        let dayPreStart = parseInt(element5.parentElement.firstChild.getAttribute('day-value'));
        this.hourPreEnd = hourPreStart
        this.dayPreEnd = dayPreStart
    }
    console.log(this.hourPreStart, this.dayPreStart, this.hourPreEnd, this.dayPreEnd)
}

您正在使用此代码:

<tbody @mousedown='mouseDown' @mouseup='mouseUp' @mousemove='mouseMove'>

但是您应该像这样将 $event 添加到处理程序中:

<tbody @mousemove='mouseMove($event)'>