From 1c7fe1c7feb1ca3ff60e69f91f17369dca393d6b Mon Sep 17 00:00:00 2001 From: P2K0 <3364148324@qq.com> Date: Thu, 1 Feb 2024 18:08:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(u-form-item):=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=A0=A1=E9=AA=8C=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #1292 --- uview-ui/components/u-form-item/u-form-item.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/uview-ui/components/u-form-item/u-form-item.vue b/uview-ui/components/u-form-item/u-form-item.vue index d6b8c8b0..86a009b6 100644 --- a/uview-ui/components/u-form-item/u-form-item.vue +++ b/uview-ui/components/u-form-item/u-form-item.vue @@ -77,6 +77,10 @@ } }, props: { + // 传递需要校验的对象 + target: { + type: Object, + }, // input的label提示语 label: { type: String, @@ -273,7 +277,12 @@ // 校验数据 validation(trigger, callback = () => {}) { // 检验之间,先获取需要校验的值 - this.fieldValue = this.parent.model[this.prop]; + if (this.target) { + this.fieldValue = this.target[this.prop]; + } else { + this.fieldValue = this.parent.model[this.prop]; + } + // blur和change是否有当前方式的校验规则 let rules = this.getFilteredRule(trigger); // 判断是否有验证规则,如果没有规则,也调用回调方法,否则父组件u-form会因为