🐛(component): 修复表单的"空指针"问题

This commit is contained in:
就眠儀式 2022-09-09 00:35:58 +08:00
parent 92021b09e9
commit beff81863f
2 changed files with 5 additions and 2 deletions

View File

@ -145,8 +145,8 @@ const clearValidate = () => {
errorStatus.value = false;
errorMsg.value = "";
const slotParentDiv = slotParent.value as HTMLDivElement;
slotParentDiv.childElementCount > 0 &&
slotParentDiv.firstElementChild?.classList.remove("layui-form-danger");
slotParentDiv?.childElementCount > 0 &&
slotParentDiv?.firstElementChild?.classList.remove("layui-form-danger");
};
defineExpose({ validate, clearValidate });

View File

@ -29,6 +29,9 @@
<lay-form-item label="描述" prop="desc">
<lay-textarea placeholder="请输入描述" v-model="model.desc"></lay-textarea>
</lay-form-item>
<lay-form-item label="时间" prop="datetime" required>
<lay-date-picker v-model="model.datetime" range type="datetime"></lay-date-picker>
</lay-form-item>
<lay-form-item>
<lay-button @click="submitClick">提交</lay-button>
</lay-form-item>