element-ui官網的table組件中提到:
通過
Scoped slot
可以獲取到 row, column, $index 和 store(table 內部的狀態管理)的數據。
使用:
<el-table-column prop="金額" label="金額(萬)" min-width="120" align="center" > <template slot-scope="scope" > <p @click="function1(scope.row.data1,'參數')">
{{scope.row['金額']|toFixedNum(param)|numFormat(param)}}
</p>
</template>
</el-table-column>
如上述代碼,可以在<template scope="scope">中通過scope.row.鍵名,獲取所在行的某一列的數據。同時可以添加點擊事件,也可以使用過濾器;
emm......關於<template scope="scope">的理解,本來想多寫點,一直很忙沒時間,等后來有空了,想想下方鏈接的作者寫的不錯,那就直接貼上這個鏈接吧: