0👍
v-on
directive accepts expression or callback function as event handler. Considring that click
is a method, @click="click"
and @click="click($event)"
behave the same way, with the latter being explicit.
setNewEmployeeName; setName()
is JS expression and it behaves like it would be evaluated outside the template; setNewEmployeeName
is not called and is a no-op, while it should be provided with field value as an argument.
It’s a good practice to not distribute JS code between template
and script
parts of a component. Instead, it can be:
@input="setName"
and
setName(event){
this.setNewEmployeeName(event.target.value);
this.$v.newEmployeeName.$touch()
}
- [Vuejs]-Wrap selected text inside div in stars vuejs
- [Vuejs]-Is it possible to rely on computed-properties-mapped-getter-values inside a created block in a Vue instance?
Source:stackexchange.com