我试图通过按钮获取设定值,以便在我的函数中进一步处理它。
<template is="dom-if" if="[[Student.Absence]]">
<td><button class="defaultbutton" value="[[Student.studentnum]]"></button></td>
<td><button class="absentbutton" value="[[Student.studentnum]]" on-click="absenceHandler(this.value)"></button></td>
</template>
absenceHandler(studID){
let DummyStudents = this.get(['DummyStudents']);
console.log(studID);
alert(DummyStudents[1]);
}
我希望将值插入到我的函数中,但我得到这个:
监听器方法absenceHandler(this.value)
未定义处理程序@ template-stamp.html:98(匿名)@templatize.html:160
无需明确地将值发送到方法。你可以按如下方式工作。
<td><button class="absentbutton" value="[[Student.studentnum]]" on-click="absenceHandler"></button></td>
absenceHandler(e){
let studID = e.currentTarget.value;
let DummyStudents = this.get(['DummyStudents']);
console.log(studID);
alert(DummyStudents[1]);
}