Skip to content

[Vue warn]: Invalid prop: type check failed for prop "checked". Expected Boolean, got Event  #1356

@liudonghua123

Description

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

Version

1.4.2

Environment

Win 10 1903, Chrome 78, vue ^2.6.10

Reproduction link

https://github.com/liudonghua123/antd-demo

Steps to reproduce

  1. vue create antd-demo
  2. vue add ant-design
  3. write a component mixed v-decorator and v-model like the following.
// FormDemo.vue
<template>
  <a-form :form="form">
    <a-form-item
      :label-col="formItemLayout.labelCol"
      :wrapper-col="formItemLayout.wrapperCol"
      label="Name"
    >
      <a-input
        v-decorator="[
          'username',
          { rules: [{ required: true, message: 'Please input your name' }] }
        ]"
        placeholder="Please input your name"
      />
    </a-form-item>
    <a-form-item
      :label-col="formItemLayout.labelCol"
      :wrapper-col="formItemLayout.wrapperCol"
      label="Nickname"
    >
      <a-input
        v-decorator="[
          'nickname',
          {
            rules: [
              { required: checkNick, message: 'Please input your nickname' }
            ]
          }
        ]"
        placeholder="Please input your nickname"
      />
    </a-form-item>
    <a-form-item
      :label-col="formTailLayout.labelCol"
      :wrapper-col="formTailLayout.wrapperCol"
    >
      <a-checkbox v-model="checkNick">
        Nickname is required
      </a-checkbox>
    </a-form-item>
    <a-form-item
      :label-col="formTailLayout.labelCol"
      :wrapper-col="formTailLayout.wrapperCol"
    >
      <a-button type="primary" @click="check">
        Check
      </a-button>
    </a-form-item>
  </a-form>
</template>

<script>
const formItemLayout = {
  labelCol: { span: 4 },
  wrapperCol: { span: 8 }
};
const formTailLayout = {
  labelCol: { span: 4 },
  wrapperCol: { span: 8, offset: 4 }
};
export default {
  data() {
    return {
      checkNick: false,
      formItemLayout,
      formTailLayout,
      form: this.$form.createForm(this, { name: "dynamic_rule" })
    };
  },
  methods: {
    check() {
      this.form.validateFields(err => {
        if (!err) {
          // console.info("success");
        }
      });
    },
  }
};
</script>
  1. Use the component in App.vue
  2. Click the checkbox in the browser page

What is expected?

No warn or error shown in console

What is actually happening?

image


The callback in model is called twice, the first one the value argument was a event object, the the second one with the correct true/false value.

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