我怀疑如何将reactjs文件加载到新窗口中
单击电子反应样板中的按钮。
const handleVideoCall=()=>{
const remote=require('electron').remote;
const BrowserWindow=remote.BrowserWindow;
const win = new BrowserWindow({
height: 600,
width: 800,
});
win.loadFile(fileName);
}
handleVideoCall 是单击按钮时调用的方法。
FileName 是我需要打开的reactjs 文件。
由于没有来自反应电子样板的文档,我一直坚持这一点。任何帮助都是值得赞赏的。
我得到了答案,我认为这对很多人都有帮助,因为没有电子反应样板的文档。
将nodeIntegration设置为true或预加载js。
const handleVideoCallNew = async number => {
const remote=require('electron').remote;
const BrowserWindow=remote.BrowserWindow;
const win = new BrowserWindow({
height: 600,
width: 800,
frame:false,
webPreferences: {
nodeIntegration: true,
}
});
win.loadURL(`file://${__dirname}/app.html#/login`);
}
并在路由器文件上
<Route path="/login" component={Login} />
通过使用此代码,我们可以打开reactjs文件并路由到登录。 app.html 是主文件,在 electro-react-boilerplate 代码中加载到 main.dev.js 中。哈希是打开reactjs 文件的最简单方法。
由于 Electron 中的 loadURL 仅加载 url 和 htmls 文件,因此我们无法打开 js 文件。所以打开主app.html并使用路由进行哈希.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)