我們經常會在某個table末尾加上操作列來放置button來處理跳轉和其他的邏輯
那么當點擊button的時候同樣也會執行在el-table 設置的 @row-click="handleRowClick"事件。如果避免這種情況呢?
其實很簡單,在操作列的加上@click.stop就可以了
<el-table @row-click="handleRowClick :data="dataList">
<el-table-column header-align="left" align="left" label="操作">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
@click.stop
@click="handleView(scope.row)"
>查看</el-button>
<el-button
v-else
size="mini"
@click.stop
@click="handleProcess(scope.row)"
>處理</el-button>
</template>
</el-table-column>
<el-table>
這樣就可以避免執行handleRowClick事件了