Vue
by Roland Doda
HTML
<div id="app">
<div class="form-group m-b-40">
<input type="text" :value="text" @input="updateValue">
<hr>
</div>
The input value is: {{text}}
</div>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
Vue
new Vue({
el: "#app",
data: {
text: ''
},
created() {
this.fetchFromApi()
},
methods: {
updateValue(value) {
let newValue = value.target.value
this.text = newValue
},
fetchFromApi() {
//get from API the input value and then set it like:
this.text = 'input value' //set the input value
}
}
})