I'm facing a tricky issue with VueJS as I am still getting acquainted with it. My objective is to access and modify variables within the data function, but so far, I haven't been successful.
The problematic line:
console.log('item: ' + this.item);
The error message reads:
TypeError: Cannot read property 'item' of undefined
Below is the snippet of my code:
data: function(){
return {
item: 69,
file: 0
};
},
methods: {
toggle: (elementId = 0, type = 'item') => {
console.log('element ID: ' + elementId);
console.log('type: ' + type);
console.log('item: ' + this.item);
switch (type) {
case 'item':
break;
case 'file':
break;
}
}
}