javascript - Vuejs single file component (.vue) model update inside the <script> tag -
i'm new vuejs , i'm trying build simple single file component testing purpose.
this component displays bool , button change bool value. listen "customevent" changes bool 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 works fine. when click on value changes. when receive event, 'event received' displayed in console bool doesn't change.
is there way access components data code?
thanks , regards, eric
you can move ipcrenderer.on(...)
vuejs's lifecycle hooks created
.
see: https://vuejs.org/v2/guide/instance.html#instance-lifecycle-hooks
Comments
Post a Comment