From 1a7f4e8352acc3a33301acf4735e511df7c0e545 Mon Sep 17 00:00:00 2001 From: liwei Date: Wed, 8 Dec 2021 22:15:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8F=91=E5=B8=83v1.2.6=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/components/index.js | 9 ++++++++- src/packages/index.vue | 2 +- .../.vuepress/components/example/array/index.vue | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/packages/components/index.js b/src/packages/components/index.js index 74bfe10..c01ea80 100644 --- a/src/packages/components/index.js +++ b/src/packages/components/index.js @@ -46,7 +46,14 @@ export const Component = (createElement, vm, key, item) => { // 组件default如果是动态, 需要重新设置该组件的value if (isEmpty(value) && typeof value !== 'boolean' && !isEmpty(item.default)) { - eval(`formValues.${name} = item.default`) + if (tag === 'el-select') { + // 下拉组件,有全部选项,全部值为空且默认值不是全部的问题 + if (!items.map(selItem => selItem[keys.value]).some(itemVal => itemVal === value)) { + eval(`formValues.${name} = item.default`) + } + } else { + eval(`formValues.${name} = item.default`) + } } // 合并事件 diff --git a/src/packages/index.vue b/src/packages/index.vue index 276d94e..fb80753 100644 --- a/src/packages/index.vue +++ b/src/packages/index.vue @@ -541,7 +541,7 @@ export default { */ getValidateProps(field) { const val = getObjectByPath(this.formValues, field) - if (typeof val !== 'object' && !Array.isArray(val)) { + if ((typeof val !== 'object' && !Array.isArray(val)) || val === null) { return [field] } else if (Array.isArray(val)) { return val.length === 0 ? [field] : val.map((item, index) => this.getValidateProps(`${field}[${index}]`)).flat(Infinity) diff --git a/vuepressdocs/.vuepress/components/example/array/index.vue b/vuepressdocs/.vuepress/components/example/array/index.vue index b647441..29f5f65 100644 --- a/vuepressdocs/.vuepress/components/example/array/index.vue +++ b/vuepressdocs/.vuepress/components/example/array/index.vue @@ -42,7 +42,7 @@ export default { id: "", }, on: { - $addRow(scope) { + delete(scope) { console.log(scope); scope.row.disabled = true; }