0👍
✅
You can use the beforeCreate
hook on the Vue
component in order to hydrate the data
property:
export default {
data: function() {
return {
files: []
};
},
beforeCreate() {
ipcRenderer.on("channel1", (e, files) => {
this.files = files
});
},
methods: {
clicked: function() {
ipcRenderer.send("channel1", "open dialog to getFiles from user");
}
}
};
Note that, of course, you cannot interact directly with the files array until you know it’s been hydrated, so a computed getter here may be of some use to you, or just use files.length
.
Source:stackexchange.com