From 4872ca0242f5d52916fe50fe7ff7eb0a89067ab4 Mon Sep 17 00:00:00 2001 From: tangofe <540548194@qq.com> Date: Thu, 28 Nov 2019 17:19:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20extraButton=E6=B7=BB=E5=8A=A0=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E7=B1=BB=E5=9E=8B=E7=9A=84disabled=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=20(#247)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/extra-buttons.md | 1 + src/el-data-table.vue | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/extra-buttons.md b/docs/extra-buttons.md index d396175b..962a0936 100644 --- a/docs/extra-buttons.md +++ b/docs/extra-buttons.md @@ -17,6 +17,7 @@ export default { extraButtons: [ { type: 'success', + disabled: row => row.date === '2016-05-04', text: row => row.status === 'normal' ? '禁用' : '启用', atClick(row) { alert(row.name) diff --git a/src/el-data-table.vue b/src/el-data-table.vue index 27fb3c9f..366e0d80 100644 --- a/src/el-data-table.vue +++ b/src/el-data-table.vue @@ -206,6 +206,7 @@ :click="btn.atClick" :params="scope.row" :callback="getList" + :disabled="'disabled' in btn ? btn.disabled(scope.row) : false" > {{ typeof btn.text === 'function' @@ -402,7 +403,7 @@ export default { }, /** * 操作列的自定义按钮, 渲染的是element-ui的button, 支持包括style在内的以下属性: - * {type: '', text: '', atClick: row => Promise.resolve(), show: row => return true时显示 } + * {type: '', text: '', atClick: row => Promise.resolve(), show: row => return true时显示, disabled: row => return true时禁用 } * 点击事件 row参数 表示当前行数据, 需要返回Promise, 默认点击后会刷新table, resolve(false) 则不刷新 */ extraButtons: {