2
私はVueの中に単純なテーブルを持っている:Vueで特定のデータ値にスクロールする方法は?
<tbody>
<tr v-for="(item, index) in items">
<td>
...
</td>
</tr>
</tbody>
items
は動的unshift
経由で追加されています。
jQuery(document).keydown((e) => {
const which = e.which;
if ([38, 40].indexOf(which) != -1) {
e.preventDefault();
if (this.active_index == null) {
this.active_index = 0;
} else {
if (e.which == 38) {
// up
this.active_index--;
} else {
// down
this.active_index++;
}
}
console.log(this.items[this.active_index])
}
});
それが何らかの形でthis.items[this.active_index]
要素またはそれにスクロールするには、その位置を取得することが可能です:主なものは、私は、私はこのようにそれをやったdown
キーので、up
を経由して、テーブルをナビゲートする必要があるということです。