WebContentsView¶
一个显示 WebContents 的 View。
进程:Main
此模块在 app 模块的 ready 事件发出之前无法使用。
const { BaseWindow, WebContentsView } = require('electron')
const win = new BaseWindow({ width: 800, height: 400 })
const view1 = new WebContentsView()
win.contentView.addChildView(view1)
view1.webContents.loadURL('https://electronjs.org')
view1.setBounds({ x: 0, y: 0, width: 400, height: 400 })
const view2 = new WebContentsView()
win.contentView.addChildView(view2)
view2.webContents.loadURL('https://github.com/electron/electron')
view2.setBounds({ x: 400, y: 0, width: 400, height: 400 })
Class: WebContentsView extends View¶
一个显示 WebContents 的 View。
进程:Main
WebContentsView 继承自 View。
WebContentsView 是一个 EventEmitter。
[!WARNING] 用户代码中无法对 Electron 的内置类进行子类化。 更多信息,请参阅 常见问题。
new WebContentsView([options])¶
optionsObject(可选)webPreferencesWebPreferences(可选)- 网页功能的设置。webContentsWebContents(可选)- 如果存在,给定的 WebContents 将被 WebContentsView 接管。一个 WebContents 一次只能在一个 WebContentsView 中显示。
创建一个 WebContentsView。
实例属性¶
使用 new WebContentsView 创建的对象具有以下属性,此外还继承了 View 的属性:
view.webContents 只读¶
一个 WebContents 属性,包含对所显示的 WebContents 的引用。
使用它来与 WebContents 交互,例如加载 URL。
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 el/electron