How does the checkbox in element-ui table achieve multiple selection of keyboard events shift?

how to implement shift multiple selection checkbox in el-table

Apr.27,2021

you can listen to shift

then make a loop check when select


my idea is to listen to the keyboard onkeypress event to determine whether it is a shift keystroke. If so, addEventListener, the row serial number of the checkbox in the first and second selected el-table, then call the toggleRowSelection event of the table, pass the line number in, and trigger the selected


thank you for the answer. Now the solution is to addEventListener, keydown and keyup in mounted if keycode is 16. Then change the true and false to the isShift variable, then watch listens for the isShift variable, after the keyup event is triggered, ask for min,max, and then loop through the table's toggleRowSelection event in the [min,max] interval. There are some more detailed situations to be taken into account, so we will not expand here.

Menu