简体   繁体   中英

Correct loadURL for building in electron app with react?

What should i put for mainWindow.loadURL in my electron app build with react? Currently i have

  mainWindow.loadURL('file://' + path.join(__dirname, '../build/index.html'));

And it works fine in development while running 'npm run electron' but when i try to build my application and start the app by clicking the application icon, I only see blanc white window.

I think this has to do with the path, but if you guys have any other ideas that might cause this feel free to tell..

I am running MacOS 10.14

This occurs because of the incorrect link between the build folder and the entry point of your application.

You can try it with a template literal like this:

mainWindow.loadURL(`file://${__dirname}/../build/index.html`);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM