new Vue({
el: "#app",
a: false,
data: {
input: null,
messages: []
},
methods:{
newMessage: function(e) {
data = {user:localStorage.getItem('user'), message: this.input};
this.messages.push(data);
this.input = null;
}
},
created: function(){
if ( !localStorage.getItem('user') ) {
localStorage.setItem("user", "Николай");
}
}
});
<div id="app">
{{ answer }}
<input v-model="userUrl">
</div>
<script>
var vm = new Vue({
el: '#app',
data: {
answer: ''
},
created: function () {
this.loadQuote()
},
methods: {
loadQuote: function() {
this.status = 'Loading...';
var vm = this;
const url = `http://toster.ru/${this.userUrl}`;
axios.get(url)
.then(function (response) {
vm.answer = response.data
})
.catch(function (error) {
vm.answer = 'error';
});
}
}
})
</script>