Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
liudonghua123 opened this issue Oct 29, 2019 · 11 comments
Labels

Comments

@liudonghua123
Copy link

liudonghua123 commented Oct 29, 2019

  • 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.

@sendya
Copy link
Member

sendya commented Oct 29, 2019

no problem
https://codesandbox.io/s/vue-antd-template-3db90

Please try using checked prop or @change

https://www.antdv.com/components/checkbox-cn/#API


vue.js 2.6.0-beta.1 What changed?

@sendya
Copy link
Member

sendya commented Oct 30, 2019 via email

@liudonghua123
Copy link
Author

@sendya Hi, I tried you codesanbox example, it's seems ok, but when you download and run locally, you will see the same errors in console.

image

@liudonghua123
Copy link
Author

I can see the same problem in codesanbox now.
image

@sendya
Copy link
Member

sendya commented Oct 30, 2019

I can see the same problem in codesanbox now.
image

vue version 2.5.22

@sendya
Copy link
Member

sendya commented Oct 30, 2019

v-model $emit input is a bug in 2.6.0-beta.1 and latest

image

@liudonghua123
Copy link
Author

It's a bug existed from vue 2.6.0-beta.1 to the latest 2.6.10?

@liudonghua123
Copy link
Author

liudonghua123 commented Oct 30, 2019

If I change a-checkbox to input type="checkbox", this error disappeared.

https://codesandbox.io/s/vue-antd-template-cxwbr?fontsize=14

tangjinzhou added a commit that referenced this issue Oct 30, 2019
@liudonghua123
Copy link
Author

@sendya @tangjinzhou Does this issue fixed?

@tangjinzhou
Copy link
Member

2e9b300 @liudonghua123

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants