目录

View

Extends: AbstractView

A native view that can contain other views.

Example 

import { BaseWindow, View, BrowserView } from '@mobrowser/api';

const browserViewOne = new BrowserView({
  url: 'https://example.com'
})

const browserViewTwo = new BrowserView({
  url: 'https://example.com'
})

const contentView = new View()
contentView.addChildView(browserViewOne)
contentView.addChildView(browserViewTwo)

browserViewOne.setBounds({
  origin: { x: 0, y: 0 },
  size: { width: 450, height: 600 }
})
browserViewTwo.setBounds({
  origin: { x: 450, y: 0 },
  size: { width: 450, height: 600 }
})

const win = new BaseWindow({
  size: { width: 900, height: 600 }
})
win.contentView.addChildView(contentView)
win.show()

Methods 

constructor() 

constructor(): void;

Creates a new view.

addChildView() 

addChildView(view: View | BrowserView, index?: number): void;

Adds a child view to this view.

Child order also defines z-order: index 0 is the back-most child, and the last child is front-most. When index is omitted, the child is added to the front.

If the child view has no explicit bounds, it fills this view and automatically resizes with it. Call setBounds() before or after adding the child to opt out of automatic resizing and use manual bounds. Call setBounds(null) to clear explicit bounds and restore automatic resizing.

ParameterTypeDescription
viewViewBrowserView
index?numberThe index at which to add the child view. If not provided, the child is added to the front.

removeChildView() 

removeChildView(view: View | BrowserView): void;

Removes a child view from this view.

ParameterTypeDescription
viewViewBrowserView