Getting Started
复制一个包含安装步骤和本插件的完整 Markdown 指南的设置提示.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-env`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/env/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
bun add @capgo/capacitor-envbunx cap sync导入
导入import { Env } from '@capgo/capacitor-env';API概述
API概述getKey
获取环境变量获取环境变量
复制到剪贴板
import { Env } from '@capgo/capacitor-env';
const result = await EnvPlugin.getKey({ key: 'API_URL' });console.log(result.value); // 'https://api.example.com'获取环境变量
“数据源”该页面是由插件生成的 src/definitions.ts当公共资源 API 上游发生变化时,请重新同步
从 Getting Started 继续
“从 Getting Started 继续”如果您正在使用 Getting Started 来规划仪表板和 API 操作,请将其连接到 使用 @capgo/capacitor-env 为在 Using @capgo/capacitor-env 中的原生功能 API 概述 为 API 概述 中的实现细节 简介 简介中的实现细节 API Keys API Keys中的实现细节 设备 简介中的实现细节