WebView

A widget that can display a web page. Since this widget requires a lot of resources it’s recommended to have no more than one instance at a time.

Import this type with “”

Navigate the WebView to the previous page if possible.

goForward()

Navigate the WebView to the next page if possible.

postMessage(message, targetOrigin)

iOSAndroid

Parameters:

  • targetOrigin: string
    • the URL of the page that receives the message. The message is only sent if the current document URL has the same scheme, domain and path. Use to send to any URL.
      *Returns:
      this

Posts a web message to the underlying window object of the WebView. The website in the WebView can register for the message in the following fashion: . For more information see Window.postMessage() API.

canGoBack

read-only Type: boolean

Whether there is a previous to navigated to via goBack().

canGoForward

read-only Type: boolean

Whether there is a next page to navigate to via goForward().

Type: string

A complete HTML document to display. Always returns the last set value.

url

Type: string

canGoBackChanged

Fired when the property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: boolean The new value of .

canGoForwardChanged

Fired when the property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: boolean The new value of .

download

Android

Fired when the WebView requests a download. The download event provides the properties url, , contentLength and contentDisposition. Supported only on Android.

Event Parameters

  • contentDisposition: string Indicates whether the download is expected to be displayed inline or to be downloaded as an attachment.

  • contentLength: number The size of the downloaded entity body.

  • mimeType: string The mime type of the resource to be downloaded.

  • url: string The URL of the resource to be downloaded.

Fired when the html property has changed.

Event Parameters

  • value: string The new value of html.

load

Fired when the url has been loaded.

message

iOSAndroid

Fired when a web message has been sent via window.parent.postMessage(message, targetOrigin) from inside the WebView.

Event Parameters

  • target: this The widget the event was fired on.

navigate

Fired when the WebView is about to navigate to a new URL.

Event Parameters

  • target: this The widget the event was fired on.

  • preventDefault: () => void Call to intercept the navigation. Not possible when the event is only an anchor navigation

  • url: string The new URL the WebView is about to navigate to.

urlChanged

Fired when the property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: string The new value of .

原文: