跳过主要内容
返回插件
@capgo/inappbrowser
教程
由 github.com/Cap-go

In App 浏览器

在应用程序中打开可自定义的网页浏览器而不离开应用程序

指南

In App 浏览器教程

使用 @capgo/inappbrowser

Capacitor 在应用浏览器中。

安装

bun add @capgo/inappbrowser
bunx cap sync

此插件暴露的内容

  • goBack - 如果可能, WebView 的历史记录中导航回去。
  • open - 在 Android 上使用 Chrome 自定义标签, 在 iOS 上使用 SFSafariViewController 打开 url 在新窗口全屏。
  • clearCookies - 当且仅当 "When" 未指定时,清除 url 的 Cookie。 id - 当且仅当 "When" 未指定时,清除所有打开的 webview 的 Cookie。
  • clearAllCookies 示例使用 id 如果可能, WebView 的历史记录中导航回去。

__CAPGO_KEEP_0__

goBack

__CAPGO_KEEP_0__

import { InAppBrowser } from '@capgo/inappbrowser';

await InAppBrowser.goBack();

open

在 Android 设备上使用 Chrome 自定义标签, 在 iOS 设备上使用 SFSafariViewController 打开 URL 全屏。

import { InAppBrowser } from '@capgo/inappbrowser';

await InAppBrowser.open({} as OpenOptions);

clearCookies

清除 URL 的 Cookie 时 id 如果省略,则适用于所有打开的网页视图。

import { InAppBrowser } from '@capgo/inappbrowser';

await InAppBrowser.clearCookies({} as ClearCookieOptions);

clearAllCookies

清除所有 Cookie 时 id 如果省略,则适用于所有打开的网页视图。

import { InAppBrowser } from '@capgo/inappbrowser';

await InAppBrowser.clearAllCookies();

完整参考