Browse Source

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
Mikael Finstad 7 years ago
parent
commit
86fcdd0bae
1 changed files with 2 additions and 14 deletions
  1. 2 14
      docs/tutorial/first-app.md

+ 2 - 14
docs/tutorial/first-app.md

@@ -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()