uview-pro 0.6.19-rc.0 → 0.6.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +10 -0
- package/components/u-form/u-form.vue +40 -0
- package/package.json +1 -1
package/changelog.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 0.6.19(2026-09-07)
|
|
2
|
+
|
|
3
|
+
### ✨ Features | 新功能
|
|
4
|
+
|
|
5
|
+
- **u-form:** 新增validateField表单校验方法,支持单个或多个字段校验(#180) ([9e77c3a](https://github.com/anyup/uView-Pro/commit/9e77c3a0dd099f831b8dccbc9e203dd433ecfda2))
|
|
6
|
+
|
|
7
|
+
### 👥 Contributors
|
|
8
|
+
|
|
9
|
+
<a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
|
|
10
|
+
|
|
1
11
|
## 0.6.18(2026-09-03)
|
|
2
12
|
|
|
3
13
|
### 🐛 Bug Fixes | Bug 修复
|
|
@@ -113,10 +113,50 @@ function validate(callback?: (valid: boolean, errorArr: ErrorItem[]) => void): P
|
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
* 校验指定字段(支持单个字段名或字段名数组)
|
|
118
|
+
* @param prop 字段名(对应 u-form-item 的 prop),可传字符串或数组
|
|
119
|
+
* @param callback 校验回调,参数为 (valid: boolean, errorArr: ErrorItem[])
|
|
120
|
+
* @returns Promise<boolean>
|
|
121
|
+
*/
|
|
122
|
+
function validateField(
|
|
123
|
+
prop: string | string[],
|
|
124
|
+
callback?: (valid: boolean, errorArr: ErrorItem[]) => void
|
|
125
|
+
): Promise<boolean> {
|
|
126
|
+
const props = Array.isArray(prop) ? prop : [prop];
|
|
127
|
+
// 从 fields 中精确匹配指定 prop
|
|
128
|
+
const targetFields = fields.value.filter((field: any) => props.indexOf(field.prop) !== -1);
|
|
129
|
+
|
|
130
|
+
return new Promise(resolve => {
|
|
131
|
+
let valid = true;
|
|
132
|
+
let count = 0;
|
|
133
|
+
let errorArr: ErrorItem[] = [];
|
|
134
|
+
if (targetFields.length === 0) {
|
|
135
|
+
resolve(true);
|
|
136
|
+
if (typeof callback === 'function') callback(true, []);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
targetFields.forEach((field: any) => {
|
|
140
|
+
// 复用 u-form-item 的 validation,确保其自身错误状态被更新/清除
|
|
141
|
+
field.validation('', (error: any) => {
|
|
142
|
+
if (error) {
|
|
143
|
+
valid = false;
|
|
144
|
+
errorArr.push({ prop: field.prop, message: error });
|
|
145
|
+
}
|
|
146
|
+
if (++count === targetFields.length) {
|
|
147
|
+
resolve(valid);
|
|
148
|
+
if (typeof callback === 'function') callback(valid, errorArr);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
116
155
|
defineExpose({
|
|
117
156
|
setRules,
|
|
118
157
|
resetFields,
|
|
119
158
|
validate,
|
|
159
|
+
validateField,
|
|
120
160
|
addField(field: any) {
|
|
121
161
|
if (!fields.value.includes(field)) fields.value.push(field);
|
|
122
162
|
},
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "uview-pro",
|
|
3
3
|
"name": "uview-pro",
|
|
4
4
|
"displayName": "【支持鸿蒙】uView Pro|基于Vue3+TS的高质量UI组件库,支持多主题、暗黑模式、多语言",
|
|
5
|
-
"version": "0.6.19
|
|
5
|
+
"version": "0.6.19",
|
|
6
6
|
"description": "uView Pro是基于Vue3+TS的多平台UI框架,提供80+高质量组件、便捷工具和常用模板,支持多主题、暗黑模式、多语言,支持H5/APP/鸿蒙/小程序多端开发。已在鸿蒙应用商店上架,欢迎体验!",
|
|
7
7
|
"main": "index.ts",
|
|
8
8
|
"module": "index.ts",
|