Now i want to get above string from creating window in main.js to pass received data from mainProcess to vue app.new Vue({ router, store, vuetify, mounted() { this.$store.dispatch('window/setWindowStat', '//SET STRING HERE') }, render: h => h(App)}).$mount('#app')推荐答案您可以通过 IPC 传递您想要的任何数据:You can pass any data you want via IPC:在主进程中:https://www.electronjs.org/docs/api/ipc-main在Renderer进程中:https://www.electronjs.org/docs/api/ipc-renderer这是一个例子:// In main process.const { ipcMain } = require('electron')ipcMain.on('hey', (event, arg) => { console.log('hey from win', arg) // prints "{a: 2}" in main process console})// send message to your window when it ready (win is your window)win.webContents.send('hi', {data: 'is here'})import { ipcRenderer } from 'electron'ipcRenderer.on('hi', (e, payload) => { console.log('hi from main', payload) // prints: {data: 'is here'} in dev tools})ipcRenderer.send('hey', 'ping', {a: 2}) 这篇关于如何使用数据创建 BrowserWindow,并在 vue 应用程序中获取该数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-02 19:19