Browse Source

文章修改

master
lniwn 6 years ago
parent
commit
37bc60ff63
  1. 14
      content/posts/2019/使用Electron+React开发跨平台桌面应用.md

14
content/posts/2019/使用Electron+React开发跨平台桌面应用.md

@ -53,7 +53,7 @@ const isDev = require('electron-is-dev');
let mainWindow; let mainWindow;
function createWindow() { function createWindow() {
mainWindow = new BrowserWindow({width: 900, height: 680}); mainWindow = new BrowserWindow({width: 900, height: 680, webPreferences: {nodeIntegration: true}});
mainWindow.loadURL(isDev ? 'http://localhost:3000' : `file://${path.join(__dirname, '../build/index.html')}`); mainWindow.loadURL(isDev ? 'http://localhost:3000' : `file://${path.join(__dirname, '../build/index.html')}`);
if (isDev) { if (isDev) {
// Open the DevTools. // Open the DevTools.
@ -399,6 +399,18 @@ F:\Project\electron\web-designer-test
``` ```
## 开发笔记
### 填坑记录
- 启动报错`'require()' is not defined.`
从Electron 5.0版本开始,`nodeIntegration`默认值由`true`改为`false`,具体可以参考[官方文档](https://github.com/electron/electron/blob/master/docs/api/breaking-changes.md#planned-breaking-api-changes-50),修改方式是在创建窗口时指定值为`true`即可。
```javascript
mainWindow = new BrowserWindow({width: 900, height: 680, webPreferences: {nodeIntegration: true}});
```
*参考文档* *参考文档*

Loading…
Cancel
Save