From 834cd8e3f08919800189c1d2710267d4aa99a8d5 Mon Sep 17 00:00:00 2001 From: GNaIq-GnAw <32642093+GNaIq-GnAw@users.noreply.github.com> Date: Mon, 6 Jan 2025 23:24:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8DForm?= =?UTF-8?q?=E7=BB=84=E4=BB=B6rules=E5=B1=9E=E6=80=A7=EF=BC=8C=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=8C=89=E7=85=A7=E9=A1=BA=E5=BA=8F=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#808)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复Form组件rules属性,没有按照顺序执行问题 (#799) * Revert "fix: 修复Form组件rules属性,没有按照顺序执行问题 (#799)" This reverts commit fc7609f964f7584c487d0d7a990a920ea96e915d. * fix: 修复Form组件rules属性,没有按照顺序执行问题 (#799) --- .../wot-design-uni/components/wd-form/wd-form.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/uni_modules/wot-design-uni/components/wd-form/wd-form.vue b/src/uni_modules/wot-design-uni/components/wd-form/wd-form.vue index 37b44517d..dd6e48a6f 100644 --- a/src/uni_modules/wot-design-uni/components/wd-form/wd-form.vue +++ b/src/uni_modules/wot-design-uni/components/wd-form/wd-form.vue @@ -148,8 +148,12 @@ function getMergeRules() { } function showMessage(errors: ErrorMessage[]) { - const messages = errors.filter((error) => error.message) + const childrenProps = children.map((e) => e.prop).filter(Boolean) + const messages = errors.filter((error) => error.message && childrenProps.includes(error.prop)) if (messages.length) { + messages.sort((a, b) => { + return childrenProps.indexOf(a.prop) - childrenProps.indexOf(b.prop) + }) if (props.errorType === 'toast') { showToast(messages[0].message) } else if (props.errorType === 'message') {