Merge pull request #7812 from electron/url-format-in-quick-start
Format URL passed to BrowserWindow.loadURL
This commit is contained in:
commit
b8f09ecf4f
1 changed files with 11 additions and 3 deletions
|
@ -81,6 +81,8 @@ example being:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const {app, BrowserWindow} = require('electron')
|
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
|
// 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.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
|
@ -91,7 +93,11 @@ function createWindow () {
|
||||||
win = new BrowserWindow({width: 800, height: 600})
|
win = new BrowserWindow({width: 800, height: 600})
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
win.loadURL(`file://${__dirname}/index.html`)
|
win.loadURL(url.format({
|
||||||
|
pathname: path.join(__dirname, 'index.html'),
|
||||||
|
protocol: 'file:',
|
||||||
|
slashes: true
|
||||||
|
}))
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
win.webContents.openDevTools()
|
win.webContents.openDevTools()
|
||||||
|
@ -225,8 +231,10 @@ repository.
|
||||||
$ git clone https://github.com/electron/electron-quick-start
|
$ git clone https://github.com/electron/electron-quick-start
|
||||||
# Go into the repository
|
# Go into the repository
|
||||||
$ cd electron-quick-start
|
$ cd electron-quick-start
|
||||||
# Install dependencies and run the app
|
# Install dependencies
|
||||||
$ npm install && npm start
|
$ npm install
|
||||||
|
# Run the app
|
||||||
|
$ npm start
|
||||||
```
|
```
|
||||||
|
|
||||||
For more example apps, see the
|
For more example apps, see the
|
||||||
|
|
Loading…
Reference in a new issue