gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 08:09:52 25 4
gpt4 key购买 nike

我有一个具有不同方法的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)
},

当我用鼠标悬停在一个字段上时,出现此错误:

enter image description here

我不知道问题出在哪里,因为 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)
}

关于vue.js - 未定义Vue.js引用错误(event.target),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59973296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com