I have a text input that has a v-model
and a v-on:change
attached to it. As the user types I update an array in data
and the UI is bound to that array. I also want to call a method to send the user input via AJAX. The data sent to the server is the result of a computed property.
<div id=app>
<input
id=user-input
type=text
v-model=userInput
v-on:change=process()>
<ul id=parsed-list>
<li v-for=item in parsedInput>
{{ item }}
</li>
</ul>
</div>
let parse = input => {
return input.split(',')
}
let serverProcess = values => {
// Send array to server
}
new Vue({
el: '#app',
data: {
userInput: ''
},
computed: {
parsedInput () {
return parse(this.userInput)
}
},
methods: {
process () {
serverProcess(this.parsedInput);
}
}
});
Is this usage of both a v-model
and v-on:change
together best practice Vue?