I'm currently having trouble using "this" in a VueJs component in the right context. I already read a lot of answers which mostly referred to not using arrow functions. As you can see in my attached code-block, I already replaced the arrow functions with regular ones and well... the context is now different but with regards to the error message
export default {
name: 'app',
components: {
Editor,
Chart,
},
methods: {
receiveValues(value1: string, value2: string) {
console.log(value1);
this.answer1 = value1; // This is where the error is thrown
console.log('receiveValues ' + this.test()); // this works just fine
},
test() {
console.log('blablabla');
return 'did it';
},
},
data() {
return {
content: 'I\'m Test Content!',
answer1: '',
answer2: '',
answer3: '',
answer4: '',
};
},
To all the people who have the same problem as I had: I still don't know why I couldn't access the right context with 'this', But I found a solution which worked for me: