> For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt.

# arrayBufferToBase64

将 ArrayBuffer 转换为 Base64 字符串。

## 扫码预览

![扫码预览 arrayBufferToBase64](https://api.qrserver.com/v1/create-qr-code/?size=200x200\&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fbasic%252Fbase64%252Findex)

## 支持版本

前端库版本不低于 `0.1.0`。

## 支持平台

<table>
<thead>
<tr><th>平台</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>Android</td><td>支持</td></tr>
<tr><td>iOS</td><td>支持</td></tr>
<tr><td>PC</td><td>支持</td></tr>
<tr><td>HarmonyOS</td><td>支持</td></tr>
</tbody>
</table>

## 支持场景

<table>
<thead>
<tr><th>场景</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>页面</td><td>支持</td></tr>
<tr><td>卡片</td><td>支持</td></tr>
</tbody>
</table>

## 调用方式

### 同步 API

```typescript
arrayBufferToBase64(buffer: ArrayBuffer): string
```

## 入参

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>buffer</code></td><td><code>ArrayBuffer</code></td><td>是</td><td>-</td><td>-</td><td>需要编码的二进制数据。</td></tr>
</tbody>
</table>

## 调用示例

```typescript
import { arrayBufferToBase64 } from '@doubao-dev/framework/api';

const base64 = arrayBufferToBase64(new Uint8Array([1, 2, 3, 4]).buffer);
console.log(base64); // AQIDBA==
```

## 返回值

标准 Base64 编码字符串。

### 返回示例

```json
"AQIDBA=="
```
