This may be a simple question but I feel like I need some clarification... I have vuejs running on a single page of my site. The vm app is running in the footer script of the page (I am not using an app.js file or templates/components etc.)
Inside one of my vue methods, this works fine:
newContainer(){
this.attribute = 'value'; //this works!
}
I am also using axios and inside its functions I have to do this instead:
axios.post('my/route', {
attribute: this.attribute //this works
}).then(function (response) {
vm.attribute = 'value'; //this works
this.attribute = 'value'; //this does not work
});
I realise this is probably due to it being in a function that this.attribute
does not work while vm.attribute
does work. However... why is this and is there a better way to do it?