优化
This commit is contained in:
@@ -81,7 +81,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, ref, watch, type PropType } from "vue";
|
||||
import { computed, nextTick, ref, watch, type PropType } from "vue";
|
||||
import type { ClInputType, PassThroughProps } from "../../types";
|
||||
import { isDark, parseClass, parsePt } from "@/cool";
|
||||
import type { ClIconProps } from "../cl-icon/props";
|
||||
|
||||
@@ -93,19 +93,27 @@ export class Form {
|
||||
}
|
||||
|
||||
class FormItem {
|
||||
public formItemRef = ref<ClFormItemComponentPublicInstance | null>(null);
|
||||
public isError: ComputedRef<boolean>;
|
||||
|
||||
constructor() {
|
||||
const { isError } = new Form();
|
||||
const ClFormItem = useParent<ClFormItemComponentPublicInstance>("cl-form-item");
|
||||
|
||||
if (this.formItemRef.value == null) {
|
||||
const ClFormItem = useParent<ClFormItemComponentPublicInstance>("cl-form-item");
|
||||
|
||||
if (ClFormItem != null) {
|
||||
this.formItemRef.value = ClFormItem;
|
||||
}
|
||||
}
|
||||
|
||||
// 监听表单字段是否验证错误
|
||||
this.isError = computed<boolean>(() => {
|
||||
if (ClFormItem == null) {
|
||||
if (this.formItemRef.value == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isError(ClFormItem.prop);
|
||||
return isError(this.formItemRef.value.prop);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user