I am missunderstanding how to update a component. So, here is the HTML :
<div id="app">
<form v-on:submit="submitForm">
<input type="text" id="txtSearch">
<input type="submit" value="go">
</form>
<br><br>
<user></user>
</div>
And the JS :
let userComponent = {
template: 'your name is : {{name}}<br>You are {{age}}'
};
let vueApp = new Vue({
el: '#app',
components: {'user': userComponent},
methods: {
submitForm: function(e) {
e.preventDefault();
let val = document.getElementById('txtSearch').value;
alert('submitted : ' + val);
// normally i do a search here : let result = mySearch(val);
// but let's do the job with this :
let result = {name: 'John', age: 27};
// so now, how to modify the <user> with this data result ?
}
}
});
So, my aim is to create a template, and of course update his data. How to do this ? I created a jsfiddle for testing : https://jsfiddle.net/4w0kh30t/1/ Thanks for your help.