recommend url.format for file URLs
This commit is contained in:
parent
d9901e62b6
commit
1985432e8e
1 changed files with 15 additions and 1 deletions
|
@ -953,6 +953,20 @@ Same as `webContents.loadURL(url[, options])`.
|
||||||
The `url` can be a remote address (e.g. `http://`) or a path to a local
|
The `url` can be a remote address (e.g. `http://`) or a path to a local
|
||||||
HTML file using the `file://` protocol.
|
HTML file using the `file://` protocol.
|
||||||
|
|
||||||
|
To ensure that file URLs are properly formatted, it is recommended to use
|
||||||
|
Node's [`url.format`](https://nodejs.org/api/url.html#url_url_format_urlobject)
|
||||||
|
method:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
let url = require('url').format({
|
||||||
|
protocol: 'file',
|
||||||
|
slashes: true,
|
||||||
|
pathname: path.join(__dirname, 'index.html')
|
||||||
|
})
|
||||||
|
|
||||||
|
win.loadURL(url)
|
||||||
|
```
|
||||||
|
|
||||||
#### `win.reload()`
|
#### `win.reload()`
|
||||||
|
|
||||||
Same as `webContents.reload`.
|
Same as `webContents.reload`.
|
||||||
|
|
Loading…
Reference in a new issue