hookehuyr

fix 错误提示优化,显示具体错误信息

1 <!-- 1 <!--
2 * @Date: 2022-07-18 10:22:22 2 * @Date: 2022-07-18 10:22:22
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-02-13 16:28:32 4 + * @LastEditTime: 2025-02-17 15:02:03
5 * @FilePath: /data-table/src/views/index.vue 5 * @FilePath: /data-table/src/views/index.vue
6 * @Description: 首页 6 * @Description: 首页
7 --> 7 -->
...@@ -1160,7 +1160,15 @@ const onSubmit = async (values) => { // 表单提交回调 ...@@ -1160,7 +1160,15 @@ const onSubmit = async (values) => { // 表单提交回调
1160 }; 1160 };
1161 1161
1162 const onFailed = (errorInfo) => { // 提交表单且验证不通过后触发 1162 const onFailed = (errorInfo) => { // 提交表单且验证不通过后触发
1163 - showToast('有填写错误,请检查') 1163 + const error_item = errorInfo.errors[0];
1164 + // 通过name找到对应的label
1165 + let error_name = '';
1166 + formData.value.forEach(item => {
1167 + if (item.key === error_item.name) {
1168 + error_name = item.component_props.label
1169 + }
1170 + });
1171 + showToast(error_name + ': ' + error_item.message);
1164 } 1172 }
1165 </script> 1173 </script>
1166 1174
......