vue+Element实现table中点击及双击事件

单击事件

<el-table
@row-click="openDetails"
>
	
</el-table>

table表格中可有很多属性,这里只写我们要用到的功能,行单击事件
script中写方法就可以了

methods:{
	openDetails(row){
    this.row = row;
    this.$router.push({
     path:'/tabs',
     query:{dis:this.row.id}
    });
   },
}

上面写的方法是通过行id传递到**‘/tab’**页面,
详细看这篇vue中选中行数据传递到下个页面

双击事件

双击事件等同于单击事件,不过属性略有改变

<el-table
@row-dblclick="openDetails"
>
</el-table>

差别在哪?只是 row-clickrow-dblclick
用起来很简单,但想不起来时是真的难!!

猜你喜欢

转载自blog.csdn.net/qq_46951524/article/details/106263505