Although it may seem like a simple question, I am in need of some clarification. Currently, I have vuejs running on a single page of my website. The vm app is running in the footer script of the page without utilizing an app.js file or templates/components.
When inside one of my vue methods, everything works perfectly fine:
newContainer(){
this.attribute = 'value'; //this works!
}
However, when using axios and within its functions, I noticed that I have to approach it differently:
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 understand that this issue could possibly be due to it being within a function where this.attribute
does not work while vm.attribute
does work. My question is why does this happen and if there is a better way to handle it?