BrowserView
History
Version(s) | Changes |
---|---|
None | API DEPRECATED |
[!NOTE] The
BrowserView
class is deprecated, and replaced by the newWebContentsView
class.
A BrowserView
can be used to embed additional web content into a BrowserWindow
. Это как дочернее окно, за исключением того, что оно позиционируется относительно его владельца окна. Он предназначен для того, чтобы быть альтернативой тега webview
.
Класс: BrowserView
History
Version(s) | Changes |
---|---|
None | API DEPRECATED |
Создание и управление видами.
[!NOTE] The
BrowserView
class is deprecated, and replaced by the newWebContentsView
class.
Process: Main
Этот модуль нельзя использовать до тех пор, пока событие ready
в app
не будет готово к использованию.
Пример
// В основном процессе.
const { app, BrowserView, BrowserWindow } = require('electron')
app.whenReady().then(() => {
const win = new BrowserWindow({ width: 800, height: 600 })
const view = new BrowserView()
win.setBrowserView(view)
view.setBounds({ x: 0, y: 0, width: 300, height: 300 })
view.webContents.loadURL('https://electronjs.org')
})
new BrowserView([options])
Experimental Deprecated
History
Version(s) | Changes |
---|---|
None | API DEPRECATED |
Свойства экземпляра
Объекты, созданные с помощью new BrowserView
, имеют следующие свойства:
view.webContents
Experimental Deprecated
History
Version(s) | Changes |
---|---|
None | API DEPRECATED |
A WebContents
object owned by this view.
Методы экземпляра
Объекты, созданные с помощью new BrowserView
, имеют следующие свойства:
view.setAutoResize(options)
Experimental Deprecated
History
Version(s) | Changes |
---|---|
None | API DEPRECATED |
None | Standardized auto-resizing behavior across all platforms |
view.setBounds(bounds)
Experimental Deprecated
History
Version(s) | Changes |
---|---|
None | API DEPRECATED |
bounds
Rectangle
Изменяет и перемещает вид в предоставленные границы относительно окна.
view.getBounds()
Experimental Deprecated
History
Version(s) | Changes |
---|---|
None | API DEPRECATED |
Returns Rectangle
bounds
этого экземпляра BrowserView как Object
.
view.setBackgroundColor(color)
Experimental Deprecated
History
Version(s) | Changes |
---|---|
None | API DEPRECATED |
color
string - Color in Hex, RGB, ARGB, HSL, HSLA or named CSS color format. The alpha channel is optional for the hex type.
Examples of valid color
values:
- Hex
#fff
(RGB)#ffff
(ARGB)#ffffff
(RRGGBB)#ffffffff
(AARRGGBB)
- RGB
rgb\(([\d]+),\s*([\d]+),\s*([\d]+)\)
- e.g.
rgb(255, 255, 255)
- e.g.
- RGBA
rgba\(([\d]+),\s*([\d]+),\s*([\d]+),\s*([\d.]+)\)
- e.g.
rgba(255, 255, 255, 1.0)
- e.g.
- HSL
hsl\((-?[\d.]+),\s*([\d.]+)%,\s*([\d.]+)%\)
- e.g.
hsl(200, 20%, 50%)
- e.g.
- HSLA
hsla\((-?[\d.]+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)
- e.g.
hsla(200, 20%, 50%, 0.5)
- e.g.
- Color name
- Options are listed in SkParseColor.cpp
- Similar to CSS Color Module Level 3 keywords, but case-sensitive.
- e.g.
blueviolet
orred
- e.g.
[!NOTE] Hex format with alpha takes
AARRGGBB
orARGB
, notRRGGBBAA
orRGB
.