Skip to content

form 表单验证a-range-picker组件是否选择日期,校验不到。 #6901

@zgl9315

Description

@zgl9315
  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

1.7.7

Environment

vuex 3.0

Reproduction link

Edit on CodeSandbox

Steps to reproduce

a-range-picker也接收不到v-modal的值,form表单校验类型type 根据官网提示写array最后还是string

提交
<script> export default { data() { return { form: {}, }; }, methods: { handelSelDate(date) { // if (date.length > 0) { // this.$nextTick(() => { // this.form.schedulingTime = [...date]; // this.$refs.ruleForm.clearValidate(["schedulingTime"]); // }); // } this.form.schedulingTime = [...date]; }, disabledDateHandler(current) { //当前周开始时间 //当前周结束时间 return ( current && !(current.isoWeekday() === 1 || current.isoWeekday() === 7) ); }, validateArray(rule, value, callback) { value = this.form.schedulingTime; if ( (value && !Array.isArray(value)) || (Array.isArray(value) && value.length == 0) ) { callback(new Error("请选择排班时间")); } else { callback(); } }, handelSubmit() { this.$refs.ruleForm.validate((valid) => { if (valid) { console.log(this.form, "111111111111"); } else { return false; } }); }, }, computed: { rules() { let rules = { schedulingTime: [ { required: true, type: "array", trigger: "change", message: "请选择排班时间", }, { validator: this.validateArray, message: "请选择排班时间" }, ], }; if (this.modelType == "oneClick") { rules["lastWeekRotation"] = [ { required: true, message: "请选择是否按照上周轮转", trigger: "change", }, ]; } return rules; }, }, }; </script>

What is expected?

如何解决日期区间校验问题

What is actually happening?

a-range-picker也接收不到v-modal的值,form表单校验类型type 根据官网提示写array最后还是string

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions