elementui表格点击事件
时间: 2023-08-22 22:09:11 浏览: 133
在Element UI的表格中,可以通过在`el-table-column`的`template`标签中添加一个`div`元素来包裹需要绑定点击事件的内容。具体的代码如下所示:
```html
<el-table :data="currentPageData" border style="width: 100%">
...
<el-table-column prop="version" label="版本号" width="250">
<template slot-scope="scope">
<!-- 将点击事件绑定在div元素 -->
<div @click="lookCfg(scope.row)">
<a href="javascript:;">{{ scope.row.version }}</a>
<el-tag type="info" size="small">历史版本</el-tag>
</div>
</template>
</el-table-column>
...
</el-table>
```
在上述代码中,通过在`div`元素上添加`@click`事件来绑定`lookCfg`方法,该方法会在点击事件触发时执行。你可以根据自己的需求来定义`lookCfg`方法的具体逻辑。
#### 引用[.reference_title]
- *1* [element ui - el-table给单元格添加点击事件](https://blog.csdn.net/qq_38374286/article/details/127851276)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [elementUI table表格行添加点击事件](https://blog.csdn.net/fd2025/article/details/125571420)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文