From 9d9622cde1824f0e6842838ff9117e4f9ea40d1a Mon Sep 17 00:00:00 2001 From: liuhanchen Date: Fri, 16 Jun 2023 15:58:32 +0800 Subject: [PATCH] feat: 优化表格条件渲染 --- packages/table/editor.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/table/editor.vue b/packages/table/editor.vue index 32487db..c4c6cf4 100644 --- a/packages/table/editor.vue +++ b/packages/table/editor.vue @@ -108,6 +108,9 @@ function editorRender(h, context, item) { const contentProps = context.props || {}; return function(scope) { const value = get(scope.row, item.prop); + if (item.if === false) { + return cellRender(h, context, item)(scope); + } if (item.if && typeof item.if === 'function') { const showEditor = item.if({ item, value, index: scope.$index, ...scope }); if (!showEditor) { @@ -118,7 +121,7 @@ function editorRender(h, context, item) { // 默认 const setValue = val => { if (get(contentProps, 'editor.force') === true) { - vnode.componentInstance.$set(scope.row, item.prop, val); + if (vnode.componentInstance) vnode.componentInstance.$set(scope.row, item.prop, val); } else { scope.row[item.prop] = val; } @@ -136,7 +139,7 @@ function editorRender(h, context, item) { const bindProp = path[0]; const propValue = cloneDeep(scope.row); set(propValue, item.prop, val); - vnode.componentInstance.$set(scope.row, bindProp, propValue[bindProp]); + if (vnode.componentInstance) vnode.componentInstance.$set(scope.row, bindProp, propValue[bindProp]); } else { setValue(val); } @@ -256,6 +259,7 @@ export default {