电子反应样板:单击按钮的子窗口 [英] electron-react-boilerplate :sub window on clicking a button

查看:55
本文介绍了电子反应样板:单击按钮的子窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我怀疑如何通过单击电子反应样板中的按钮在
上将reactjs文件加载到新窗口中。

i have a doubt that how the reactjs file can be loaded into a new window on clicking a button in electron-react-boilerplate.



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文件。
因为没有来自react-electron-boilerplate的文档,所以我坚持了这一点。任何帮助都是可观的。

handleVideoCall is the method which is called on clicking the button. FileName is the reactjs file that i needed to open. As there is no documentation from react-electron-boilerplate i was stuck with this. Any help is appreciable.


推荐答案

我得到了答案,我认为这对很多人都将有所帮助没有电子反应样板文件。
使nodeIntegration为true或预加载js。

i got the answer i think that this will be helpful for lot of peoples as there are no documentation for electron-react-boilerplate. Make the nodeIntegration to true or preload 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是主文件,该文件以电子反应样板代码加载到main.dev.js中。散列是打开reactjs文件的最简单方法。
由于电子中的loadURL仅加载url和htmls文件,因此我们无法打开js文件。 因此打开main.html并使用路由进行哈希

By using this code we can open the reactjs file and route to login. The app.html is main file which is loaded in main.dev.js in electron-react-boilerplate code. The hashing is simplest method to open the reactjs file. As the loadURL in electron only loads urls and htmls files we can't open js files. So open the main app.html and hash using routes.

这篇关于电子反应样板:单击按钮的子窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆