浏览器
Browser API 使得打开应用内浏览器会话以显示外部 Web 内容、处理认证流程等变得简单。
在 iOS 上,它使用 SFSafariViewController,并符合主流 oAuth 服务的应用内浏览器要求。
import { Plugins } from '@capacitor/core';
const { Browser } = Plugins;
await Browser.open({ url: 'http://capacitorjs.com/' });
API
open(...)
open(options: BrowserOpenOptions) => Promise<void>
使用给定的 URL 打开页面
| 参数 | 类型 |
|---|---|
options | |
prefetch(...)
prefetch(options: BrowserPrefetchOptions) => Promise<void>
提示浏览器将要访问给定的 URL,以改善初始加载时间。
仅在 Android 上有效,在 iOS 上是空操作
| 参数 | 类型 |
|---|---|
options | |
close()
close() => Promise<void>
关闭打开的浏览器。仅在 iOS 和 Web 环境中有效,否则是空操作
addListener(...)
addListener(eventName: 'browserFinished', listenerFunc: (info: any) => void) => PluginListenerHandle
| 参数 | 类型 |
|---|---|
eventName | "browserFinished" |
listenerFunc | (info: any) => void |
返回:
PluginListenerHandle
addListener(...)
addListener(eventName: 'browserPageLoaded', listenerFunc: (info: any) => void) => PluginListenerHandle
| 参数 | 类型 |
|---|---|
eventName | "browserPageLoaded" |
listenerFunc | (info: any) => void |
返回:
PluginListenerHandle