WebViewHandle
What a WebView's ref holds.
Verwendung
Reload and scroll an embedded page.
// Reload and scroll an embedded page.
import { Button, WebView, ref, type WebViewHandle } from 'kuito';
function Article() {
const page = ref<WebViewHandle>();
return (
<>
<WebView ref={page} src="https://example.com/article" flex={1} />
<Button onPress={() => void page.current?.injectJavaScript('window.scrollTo(0, 0)')}>
Top
</Button>
<Button onPress={() => void page.current?.reload()}>Reload</Button>
</>
);
}Typdeklaration
export type WebViewHandle = NativeViewHandle<WebViewMethods>;Mitglieder 15
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
idschreibgeschützt | string | Ja | — |
parentschreibgeschützt | ElementHandle | Ja | — |
childrenschreibgeschützt | ElementHandle[] | Ja | — |
focus | () => void | Ja | — |
blur | () => void | Ja | — |
setProperty | <K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null) => void | Ja | Sets a native prop on the view now, until its binding writes it again. |
addEventListener | (type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;}) => void | Ja | — |
removeEventListener | (type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean;}) => void | Ja | — |
dispatchEvent | (event: { type: string; bubbles?: boolean; cancelable?: boolean;}) => boolean | Ja | Sends an event through the tree, capture to bubble, as a native one travels:
a KuitoCustomEvent, or any object with a type. False when a listener
called preventDefault() on a cancelable event. |
goBack | () => Promise<void> | Ja | — |
goForward | () => Promise<void> | Ja | — |
reload | () => Promise<void> | Ja | — |
stop | () => Promise<void> | Ja | — |
injectJavaScript | (script: string) => Promise<void> | Ja | Runs script in the main frame; its result and errors stay in the page. |
postMessage | (data: string) => Promise<void> | Ja | Dispatches a message event on the page's window, with data as event.data. |
focus — Methodensignaturen
Signaturen
(): voidParameter
Keine Parameter.
Rückgabe
void
blur — Methodensignaturen
Signaturen
(): voidParameter
Keine Parameter.
Rückgabe
void
setProperty — Methodensignaturen
Signaturen
<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null): voidTypparameter
| Name | Einschränkung | Standard |
|---|---|---|
K | keyof ElementProperties | — |
Parameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
key | K | Ja | — |
value | ElementProperties[K] | Ja | — |
Rückgabe
void
addEventListener — Methodensignaturen
Signaturen
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal; }): voidParameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
type | string | Ja | — |
fn | (e: KuitoNativeEvent) => void | Ja | — |
options | boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;} | Nein | — |
Rückgabe
void
removeEventListener — Methodensignaturen
Signaturen
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; }): voidParameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
type | string | Ja | — |
fn | (e: KuitoNativeEvent) => void | Ja | — |
options | boolean | { capture?: boolean;} | Nein | — |
Rückgabe
void
dispatchEvent — Methodensignaturen
Signaturen
(event: { type: string; bubbles?: boolean; cancelable?: boolean; }): booleanParameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
event | { type: string; bubbles?: boolean; cancelable?: boolean;} | Ja | — |
Rückgabe
boolean
goBack — Methodensignaturen
Signaturen
(): Promise<void>Parameter
Keine Parameter.
Rückgabe
Promise<void>
goForward — Methodensignaturen
Signaturen
(): Promise<void>Parameter
Keine Parameter.
Rückgabe
Promise<void>
reload — Methodensignaturen
Signaturen
(): Promise<void>Parameter
Keine Parameter.
Rückgabe
Promise<void>
stop — Methodensignaturen
Signaturen
(): Promise<void>Parameter
Keine Parameter.
Rückgabe
Promise<void>
injectJavaScript — Methodensignaturen
Signaturen
(script: string): Promise<void>Parameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
script | string | Ja | — |
Rückgabe
Promise<void>
postMessage — Methodensignaturen
Signaturen
(data: string): Promise<void>Parameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
data | string | Ja | — |
Rückgabe
Promise<void>
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.