I have the following simple VueJS app:
window.Vue = require('vue');
new Vue({
el : '#break-container',
data : {
pool_break : {
'name' : '',
'description' : '',
'three_point_break' : false
}
},
methods : {
fetchBreak : function(){
axios.get('/break-axios').then(function(response){
this.pool_break = response.data.break;
console.log(this.pool_break);
}.bind(this));
},
},
mounted : function(){
this.fetchBreak();
},
});
The response from axios comes in correctly, and console.log prints out:
description: "description here"
id: 4
name: "9 ball"
three_point_break: null
user_id: 1
But in my HTML, pool_break.nam
e fails to show:
<div class="container" id="break-container">
@{{ pool_break.name }}
</div>
This shows up as blank when the page loads. How do I fix this?
I have tried setting the parameters more directly, like:
this.pool_break.name = response.data.break.name;
But the result is the same.