I'm working on a text input that is using the v-model
to bind its value to data
. I also need to trigger my parse()
function whenever the value of this v-model
changes, so that I can update an array within the data
object.
<div id="app">
<input
id="user-input"
type="text"
v-model="userInput">
<ul id="parsed-list">
<li v-for="item in parsedInput">
{{ item }}
</li>
</ul>
</div>
new Vue({
el: '#app',
data: {
userInput: '',
parsedInput: []
}
})
let parse = input => {
return input.split(',')
}
What is the best approach to update data.parsedInput
with the parse()
function whenever the v-model value changes? I'm looking for the proper Vue method to achieve this.