Explorar el Código

表单提交可滚动到错误块

icssoa hace 7 meses
padre
commit
93be8d8b5d

+ 1 - 0
pages/demo/form/form.uvue

@@ -62,6 +62,7 @@
 							<cl-checkbox
 								v-model="formData.tags"
 								v-for="(item, index) in tagsOptions"
+								:key="index"
 								:value="index"
 								:pt="{
 									className: 'mr-5 mt-2'

+ 2 - 2
uni_modules/cool-ui/components/cl-form/cl-form.uvue

@@ -15,7 +15,7 @@
 
 <script setup lang="ts">
 import { computed, getCurrentInstance, nextTick, ref, watch, type PropType } from "vue";
-import { isEmpty, isString, parsePt, parseToObject } from "@/cool";
+import { isEmpty, isNull, isString, parsePt, parseToObject } from "@/cool";
 import type { ClFormLabelPosition, ClFormRule, ClFormValidateError } from "../../types";
 import { $t, t } from "@/locale";
 import { usePage } from "../../hooks";
@@ -297,7 +297,7 @@ function scrollToError(prop: string) {
 			.in(component)
 			.select(".cl-form-item--error")
 			.boundingClientRect((res) => {
-				if (res != null) {
+				if (!isNull(res)) {
 					page.scrollTo(((res as NodeInfo).top ?? 0) + page.getScrollTop());
 				}
 			})