typescript在渲染进程中调用electron的API,报错xxx is not a function或electron is undefined,解决办法:
// 在调用electron相关函数之前加上环境判断
if (typeof window !== 'undefined' && typeof (window as any)['electron'] !== 'undefined') {
(window as any)['electron'].ipcRenderer.on(channel, callback);
}

被折叠的 条评论
为什么被折叠?



