[Vuejs]-Vue v-model naming best practice

0👍

This is not question related to v-model. v-model is just binding to component’s data and what you are asking of these properties.

There is no general rule. Both of your examples can be right in different cases.
Readability counts.

I would use first eg. for Customer component. Where it’s clear that surname is customer attribute and repeating word customer in property names is redundant.

Using customer.surname may adequate in cases where component keeps multiple object, not only customer and you want to be clear where surname belongs.

Also when passing customer as object from parent component you probably ends with binding to customer.surname

Leave a comment