Discovering the world of vuejs, I set out to create a basic single file component for testing purposes.
This component's main task is to showcase a boolean and a button that toggles the boolean value. It also listens for a "customEvent" which triggers another change in the boolean value.
<template>
{{ mybool }}
<button v-on:click="test">test</button>
</template>
<script>
ipcRenderer.on('customEvent', () => {
console.log('event received');
this.mybool = !this.mybool;
});
export default {
data() {
return {
mybool: true,
};
},
methods: {
test: () => {
console.log(mybool);
mybool = !mybool;
},
},
};
</script>
The button behaves as expected - clicking it results in a value change. However, when the event is triggered, 'event received' is logged to the console but the boolean remains unchanged.
I'm wondering if there's a way to access the component's data from my code.
Appreciate your help, Eric