How to get v-model expression?

I need expression passed in v-model to detect property name.


<input-component v-model="" />

Why do I need expression?
If the expression is available then input components can fetch relevant errors from injected error collection object.

Until v2.1, we could get expression using this.$

1 Like

Seems this isn’t possible, see my re-post of the question here:

Check mounted method in

This is not part of public API and can change anytime.

v-model is merely syntax sugar ( so perhaps you can find your solution by looking at v-bind

  v-on:input="something = $">

If you find nothing there, the first thing that comes to mind could be using a prop to assist you in matching your keys.

znck’s answer seems to work well – this.$

I’ll ask if this can be brought into the public API given that it’s already there and useful for frameworks.

1 Like

Note: for v-model="field_name"
In vue2: node.$
In vue3: node.$attrs['onUpdate:modelValue'].toString() returns $event => ((_ctx.field_name) = $event), so you can get your field_name from there.
(but it’s not public api…)