仅供参考
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>login</title>
<style>
#app {
width: 100Vh;
height: 100Vw;
}
table{
width: 500px;
}
</style>
</head>
<body>
<div id="app">
<table border="" @mousedown="myClick()" @mouseup="endClick">
<tr><th>Header</th></tr>
<tr v-for="(item,index) in 10" @mouseout="getTrIndex(index)"><td>Data</td></tr>
</table>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
window.onload = function() {
var vm = new Vue({
el: "#app",
data: {
oper:false
},
methods: {
myClick() {
this.oper = true
},
endClick() {
this.oper = false
},
getTrIndex(index){
if(this.oper){
console.log(index)
}
}
}
})
}
</script>
</body>
</html>