# description 清单成员

> description 成员用一段文字说明 Web 应用做什么；Chrome 88 与 Edge 88 会在增强安装对话框里展示它，Firefox 与 Safari 解析后不做任何处理。

`description` 是一个字符串，说明这个 Web 应用是做什么的。W3C Application Information 注册表把它
定义为商店列表元数据；Chromium 还会在增强安装对话框里把它和 `screenshots` 一起展示给用户，并把它
作为已安装应用的无障碍描述。

Chrome 88、Edge 88、Samsung Internet 15.0 与 Android WebView 88 读取该成员（BCD
`html.manifest.description`）。Firefox 157 与 Safari 27 解析它不报错，但不在任何地方显示；在
Firefox for Android 上该属性完全没有效果。

## 成员

- **类型**：字符串。纯文本；HTML 不会被解释，换行在安装对话框里会被合并。
- **默认值**：缺省。没有 `description` 时，Chrome 的安装对话框只显示名称、来源与图标，商店列表
  则退回打包工具另行索取的文字。
- **示例值**：`"Track your habits and build streaks, even offline."`。

值不是字符串时，解析器用通用提示 `property 'description' ignored, type string expected.` 丢弃它。
格式本身没有长度上限，但 Chrome 的安装界面会截断，字符串超过 300 个字符时 DevTools 会给出警告。
把第一句写成能独立成立的话。

该成员是默认语言的文本。`description_localized`（见本地化条目）按 BCP 47 语言标签携带各语言
版本；没有与界面语言匹配的版本时，Chromium 回退到 `description`。

:::observed
Chrome 155（macOS 26，英文界面）的 DevTools > Application > Manifest：`description` 达到 301 个
字符或更长时，**Errors and warnings** 下会多出一行 `Description may be truncated.`（阈值在
DevTools 的 `AppManifestView.ts` 中写作 `description.length > 300`）。**Identity** 一节的
**Description** 仍会显示完整字符串。
:::

## 示例

两个示例使用同一段文字，区别在于谁来读它。

### 写一段经得起截断的描述

把差异化卖点放进第一个分句，整段控制在 300 字符以内并留出余量。第二句丢掉也不影响理解。

```json
{
  "name": "Habit Ledger",
  "short_name": "Habits",
  "description": "Track daily habits and build streaks, fully offline. Export to CSV, sync when you are back online, no account needed.",
  "screenshots": [
    { "src": "/shots/narrow-1.png", "sizes": "1080x1920", "type": "image/png", "form_factor": "narrow" }
  ]
}
```

Android 上的 Chrome 94 与桌面端的 Chrome 105 只有在至少存在一张截图时才会在增强安装对话框里
渲染这段文字；没有 `screenshots` 的普通对话框不显示描述。

### 在部署测试里检查上线的描述

没有 API 能报告浏览器或商店是否使用了这段文字。测试能做的是断言已部署的清单带有非空字符串且在
截断预算之内。回退分支处理没有 document 的环境（例如 Node 测试运行器）。

```js
export async function describedManifest(manifestUrl = '/manifest.webmanifest') {
  const manifest = await fetch(manifestUrl).then((r) => r.json());
  const text = manifest.description;
  if (typeof text !== 'string' || text.trim() === '') {
    return { ok: false, reason: 'description missing' };
  }
  if (text.length > 300) {
    return { ok: false, reason: `description is ${text.length} chars; Chrome truncates past 300` };
  }
  return { ok: true, text };
}
```

每次部署后对生产地址跑一遍：会剥离或改写清单的 CDN 会先在这里暴露，而不是等到安装对话框里才
被发现。

## 另请参阅

- [categories 清单成员](/zh/reference/manifest/categories/)
- [screenshots 清单成员](/zh/reference/manifest/screenshots/)
- [lang、dir 与 *_localized 清单成员](/zh/reference/manifest/localization/)
- [更丰富的安装 UI：用描述和截图增强安装提示](/zh/reference/installation/richer-install-ui/)
- [Web App Manifest - Application Information: description member](https://w3c.github.io/manifest-app-info/#description-member)（w3c.github.io）
- [Provide a custom install experience](https://web.dev/articles/customize-install)（web.dev）