зеркало из https://github.com/electron/electron.git
docs: Simplify loading of html in example (#13013)
* Simplify loading of html See new api: https://github.com/electron/electron/pull/11565 * Update first-app.md * Update first-app.md
This commit is contained in:
Родитель
265aa3da29
Коммит
86fcdd0bae
|
@ -106,19 +106,13 @@ for the application to be ready and open a window:
|
|||
|
||||
```javascript
|
||||
const {app, BrowserWindow} = require('electron')
|
||||
const path = require('path')
|
||||
const url = require('url')
|
||||
|
||||
function createWindow () {
|
||||
// Create the browser window.
|
||||
win = new BrowserWindow({width: 800, height: 600})
|
||||
|
||||
// and load the index.html of the app.
|
||||
win.loadURL(url.format({
|
||||
pathname: path.join(__dirname, 'index.html'),
|
||||
protocol: 'file:',
|
||||
slashes: true
|
||||
}))
|
||||
win.loadFile('index.html')
|
||||
}
|
||||
|
||||
app.on('ready', createWindow)
|
||||
|
@ -131,8 +125,6 @@ windows on macOS if the user clicks on the app's icon in the dock.
|
|||
|
||||
```javascript
|
||||
const {app, BrowserWindow} = require('electron')
|
||||
const path = require('path')
|
||||
const url = require('url')
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
@ -143,11 +135,7 @@ function createWindow () {
|
|||
win = new BrowserWindow({width: 800, height: 600})
|
||||
|
||||
// and load the index.html of the app.
|
||||
win.loadURL(url.format({
|
||||
pathname: path.join(__dirname, 'index.html'),
|
||||
protocol: 'file:',
|
||||
slashes: true
|
||||
}))
|
||||
win.loadFile('index.html')
|
||||
|
||||
// Open the DevTools.
|
||||
win.webContents.openDevTools()
|
||||
|
|
Загрузка…
Ссылка в новой задаче