I'm new to vue.js. It seems Two-way binding of vue.js only listens to input event from user, if you change value by JS, vue.js's value is not updated
Here is an example for what I mean:
function setNewValue() {
document.getElementById('my-field').value = 'New value';
}
new Vue({
el: '#app',
data: {
message: 'Old value'
}
})
<script src=https://cdn.jsdelivr.net/vue/latest/vue.js></script>
<div id=app>
<p>{{ message }}</p>
<input id=my-field v-model=message>
</div>
<button onclick=setNewValue()>Set new value</button>
If you click Set new value button, the field's value is changed to New value but the text above it is still Old value instead of New value. But if you change the text in the field directly, the text above is changed synchronously.
Is there anyway we can do this synchronous when updating value with JavaScript?