Object value coerced to string in event values
Version
3.2.0-beta.4
Reproduction link
Steps to reproduce
- Create any input with an object-type value (E.g.
<input type="checkbox" :value="{ a: 'A' }" />
) - Add a
v-on:change
value to the input - Check
typeof(event.target.value)
What is expected?
event.target.value
should return the object specified in value
(as is assumed at https://v3.vuejs.org/guide/component-custom-events.html#v-model-arguments ).
What is actually happening?
event.target.value
returns the String "[object Object]".
When using components, and passing in a v-model, I intend to use $emit("update:modelValue", event.target.value) to pass the proper parameter as selected by a
see https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLSelectElement
HTMLSelectElement.value A DOMString reflecting the value of the form control. Returns the value property of the first selected option element if there is one, otherwise the empty string.
that's means event.target.value
always be a string.
you should use v-model
instead.