WebViewHandle
What a WebView's ref holds.
Utilisation
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>
</>
);
}Déclaration du type
export type WebViewHandle = NativeViewHandle<WebViewMethods>;Membres 15
| Nom | Type | Requis | Description |
|---|---|---|---|
idlecture seule | string | Oui | — |
parentlecture seule | ElementHandle | Oui | — |
childrenlecture seule | ElementHandle[] | Oui | — |
focus | () => void | Oui | — |
blur | () => void | Oui | — |
setProperty | <K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null) => void | Oui | 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 | Oui | — |
removeEventListener | (type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean;}) => void | Oui | — |
dispatchEvent | (event: { type: string; bubbles?: boolean; cancelable?: boolean;}) => boolean | Oui | 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> | Oui | — |
goForward | () => Promise<void> | Oui | — |
reload | () => Promise<void> | Oui | — |
stop | () => Promise<void> | Oui | — |
injectJavaScript | (script: string) => Promise<void> | Oui | Runs script in the main frame; its result and errors stay in the page. |
postMessage | (data: string) => Promise<void> | Oui | Dispatches a message event on the page's window, with data as event.data. |
focus — signatures de méthode
Signatures
(): voidParamètres
Aucun paramètre.
Retourne
void
blur — signatures de méthode
Signatures
(): voidParamètres
Aucun paramètre.
Retourne
void
setProperty — signatures de méthode
Signatures
<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null): voidParamètres de type
| Nom | Contrainte | Par défaut |
|---|---|---|
K | keyof ElementProperties | — |
Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
key | K | Oui | — |
value | ElementProperties[K] | Oui | — |
Retourne
void
addEventListener — signatures de méthode
Signatures
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal; }): voidParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
type | string | Oui | — |
fn | (e: KuitoNativeEvent) => void | Oui | — |
options | boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;} | Non | — |
Retourne
void
removeEventListener — signatures de méthode
Signatures
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; }): voidParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
type | string | Oui | — |
fn | (e: KuitoNativeEvent) => void | Oui | — |
options | boolean | { capture?: boolean;} | Non | — |
Retourne
void
dispatchEvent — signatures de méthode
Signatures
(event: { type: string; bubbles?: boolean; cancelable?: boolean; }): booleanParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
event | { type: string; bubbles?: boolean; cancelable?: boolean;} | Oui | — |
Retourne
boolean
goBack — signatures de méthode
Signatures
(): Promise<void>Paramètres
Aucun paramètre.
Retourne
Promise<void>
goForward — signatures de méthode
Signatures
(): Promise<void>Paramètres
Aucun paramètre.
Retourne
Promise<void>
reload — signatures de méthode
Signatures
(): Promise<void>Paramètres
Aucun paramètre.
Retourne
Promise<void>
stop — signatures de méthode
Signatures
(): Promise<void>Paramètres
Aucun paramètre.
Retourne
Promise<void>
injectJavaScript — signatures de méthode
Signatures
(script: string): Promise<void>Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
script | string | Oui | — |
Retourne
Promise<void>
postMessage — signatures de méthode
Signatures
(data: string): Promise<void>Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
data | string | Oui | — |
Retourne
Promise<void>
Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.