Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

渲染进程导入ipcRenderer会出错 @@ #1

Open
cgisky1980 opened this issue Jun 29, 2023 · 2 comments
Open

渲染进程导入ipcRenderer会出错 @@ #1

cgisky1980 opened this issue Jun 29, 2023 · 2 comments

Comments

@cgisky1980
Copy link

渲染进程导入ipcRenderer会出错 @@

@kingyue737
Copy link
Owner

kingyue737 commented Jun 29, 2023

因为我没打开nodeIntegration,官方不推荐这么做https://www.electronjs.org/docs/latest/tutorial/security#3-enable-context-isolation 。你可以在preload.ts中导入ipcRenderer再把接口暴露给渲染进程。

如果无所谓,只要写代码方便就行了,那可以把nodeIntegration打开:

// In the main process.
const win = new BrowserWindow({
  webPreferences: {
    nodeIntegration: true
  }
})

@cgisky1980
Copy link
Author

打开也不行 好像因为vite的关系 我参考preload的例子 搞定了 感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants