WebViewHandle
What a WebView's ref holds.
Utilização
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>
</>
);
}Declaração do tipo
export type WebViewHandle = NativeViewHandle<WebViewMethods>;Membros 15
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
idsó de leitura | string | Sim | — |
parentsó de leitura | ElementHandle | Sim | — |
childrensó de leitura | ElementHandle[] | Sim | — |
focus | () => void | Sim | — |
blur | () => void | Sim | — |
setProperty | <K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null) => void | Sim | 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 | Sim | — |
removeEventListener | (type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean;}) => void | Sim | — |
dispatchEvent | (event: { type: string; bubbles?: boolean; cancelable?: boolean;}) => boolean | Sim | 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> | Sim | — |
goForward | () => Promise<void> | Sim | — |
reload | () => Promise<void> | Sim | — |
stop | () => Promise<void> | Sim | — |
injectJavaScript | (script: string) => Promise<void> | Sim | Runs script in the main frame; its result and errors stay in the page. |
postMessage | (data: string) => Promise<void> | Sim | Dispatches a message event on the page's window, with data as event.data. |
focus — assinaturas de método
Assinaturas
(): voidParâmetros
Sem parâmetros.
Devolve
void
blur — assinaturas de método
Assinaturas
(): voidParâmetros
Sem parâmetros.
Devolve
void
setProperty — assinaturas de método
Assinaturas
<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null): voidParâmetros de tipo
| Nome | Restrição | Predefinição |
|---|---|---|
K | keyof ElementProperties | — |
Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
key | K | Sim | — |
value | ElementProperties[K] | Sim | — |
Devolve
void
addEventListener — assinaturas de método
Assinaturas
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal; }): voidParâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
type | string | Sim | — |
fn | (e: KuitoNativeEvent) => void | Sim | — |
options | boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;} | Não | — |
Devolve
void
removeEventListener — assinaturas de método
Assinaturas
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; }): voidParâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
type | string | Sim | — |
fn | (e: KuitoNativeEvent) => void | Sim | — |
options | boolean | { capture?: boolean;} | Não | — |
Devolve
void
dispatchEvent — assinaturas de método
Assinaturas
(event: { type: string; bubbles?: boolean; cancelable?: boolean; }): booleanParâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
event | { type: string; bubbles?: boolean; cancelable?: boolean;} | Sim | — |
Devolve
boolean
goBack — assinaturas de método
Assinaturas
(): Promise<void>Parâmetros
Sem parâmetros.
Devolve
Promise<void>
goForward — assinaturas de método
Assinaturas
(): Promise<void>Parâmetros
Sem parâmetros.
Devolve
Promise<void>
reload — assinaturas de método
Assinaturas
(): Promise<void>Parâmetros
Sem parâmetros.
Devolve
Promise<void>
stop — assinaturas de método
Assinaturas
(): Promise<void>Parâmetros
Sem parâmetros.
Devolve
Promise<void>
injectJavaScript — assinaturas de método
Assinaturas
(script: string): Promise<void>Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
script | string | Sim | — |
Devolve
Promise<void>
postMessage — assinaturas de método
Assinaturas
(data: string): Promise<void>Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
data | string | Sim | — |
Devolve
Promise<void>
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.