Skip to content
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

When using v-model on a component element, the value prop is always a String #3179

Closed
LinusBorg opened this issue Jun 29, 2016 · 2 comments
Closed
Labels

Comments

@LinusBorg
Copy link
Member

LinusBorg commented Jun 29, 2016

Vue.js version

v2.0.0-alpha.8

Reproduction Link

https://jsfiddle.net/nf02Ltct/2/

Steps to reproduce

  • open console
  • read warning

What is Expected?

the special "value" prop which is passed from v-model on the component element in the template, shuold contain a Boolean value, since the parent passes a Boolean to v-model

What is actually happening?

[Vue warn]: Invalid prop: type check failed for prop "value". Expected Boolean, got String. (found in component: )

Suspicion:

I think it has something to do with whith this comment:

https://github.com/vuejs/vue/blob/v2.0.0-alpha.8/src/platforms/web/runtime/modules/props.js#L20-L21

@yyx990803
Copy link
Member

Fixed this, and also introduced a small breaking change: the component can now directly emit the value:

this.$emit('input', value)

Instead of

this.$emit('input', { target: { value }})

This also means when emitting the value of a native event you will need to do

this.$emit('input', e.target.value)

@LinusBorg
Copy link
Member Author

Thanks for the quick fix.

I like the change, it fits with the usual procedure of passing event.target.value when emitting/dispatching events today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants