I have a needed to create a local variable in my Vue template to shorten references to an otherwise long object $v.form.text
, as shown in the example below:
<input
:class="{ error: !$v.form.text.required }"
v-model.trim="$v.form.text.$model"
/>
I would like to be able to access the $v.form.text
nested object in my template as simply text
.
<input
:class="{ error: !text.required }"
v-model.trim="text.$model"
/>
There is usually a lot more code than in the example above, justifying creating a temporary variable, but the problem is the same as shown.
Note: I have already solved this, please see answer below, and simply want to document the solution for others who might be searching for the same.