# @anypoint-web-components/anypoint-collapse 中文文档

规范地址：https://npmcn.com/package/%40anypoint-web-components/anypoint-collapse/

版本：0\.1\.3
npm 元数据更新时间：2026-04-07T19:31:23.584Z
中文译文更新时间：2026-11-06T13:41:06.129Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40anypoint-web-components/anypoint-collapse
原文对照：https://npmcn.com/package/%40anypoint-web-components/anypoint-collapse/?lang=original
项目主页：https://github.com/anypoint-components/anypoint-collapse#readme
源码仓库：https://github.com/anypoint-components/anypoint-collapse

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：17.3 kB，10 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：未声明
- 运行依赖：3 个
- 首次发布：2020-06-16T00:53:13.307Z
- 最新版本发布：2021-10-15T22:39:36.812Z
- 近 30 天下载量：3082（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 0 个）

## 中文简介

铁-相撞元素的现代端口. 它形成了一个可折叠的内容块.

## 安装

```sh
npm install @anypoint-web-components/anypoint-collapse
```

也可以使用：`pnpm add @anypoint-web-components/anypoint-collapse`、`yarn add @anypoint-web-components/anypoint-collapse`、`bun add @anypoint-web-components/anypoint-collapse`

## README

# 折旧

此组件已移至 `anypoint-web-components/awc`。 。 。 .

* * *

铁-相撞元素的现代端口. 它形成了一个可折叠的内容块. 默认内容会倒塌. 使用 `opened` 或者说 `toggle()` 显示/隐藏内容.

该元素会调整相撞元素的最大高度/最大宽以显示/隐藏内容. 避免在可折叠物上直接放入垫板/边框/边框,而是在内部放入一个凹槽并以此为样式.

[![tests](https://github.com/anypoint-web-components/anypoint-collapse/actions/workflows/deployment.yml/badge.svg)](https://github.com/anypoint-web-components/anypoint-collapse/actions/workflows/deployment.yml)

[![Published on NPM](https://img.shields.io/npm/v/@anypoint-web-components/anypoint-collapse.svg)](https://www.npmjs.com/package/@anypoint-web-components/anypoint-collapse)

## 使用量

### 安装

```sh
npm install @anypoint-web-components/anypoint-collapse --save
```

### 在 HTML 文档中

```html
<script type="module" src="@anypoint-web-components/anypoint-collapse/anypoint-collapse.js"></script>

<anypoint-collapse>
  <div class="content">
    Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea, id minim maiestatis incorrupte duo. Dolorum verterem ad ius, his et nullam verterem. Eu alia debet usu, an doming tritani est. Vix ad ponderum petentium suavitate, eum
    eu tempor populo, graece sententiae constituam vim ex. Cu torquatos reprimique neglegentur nec, voluptua periculis has ut, at eos discere deleniti sensibus. Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea,
    id minim maiestatis incorrupte duo. Dolorum verterem ad ius, his et nullam verterem. Eu alia debet usu, an doming tritani est. Vix ad ponderum petentium suavitate, eum eu tempor populo, graece sententiae constituam vim ex. Cu torquatos reprimique
    neglegentur nec, voluptua periculis has ut, at eos discere deleniti sensibus.
  </div>
</anypoint-collapse>
```

### 在一个LitElement中

```js
import { LitElement, html } from 'lit-element';
import '@anypoint-web-components/anypoint-collapse/anypoint-collapse.js';

class SimpleElement extends LitElement {
  render() {
    return html`
    <anypoint-collapse>
      ${this.content}
    </anypoint-collapse>
    `;
  }
}
window.customElements.define('simple-element', SimpleElement);
```

## 发展

```sh
git clone https://github.com/anypoint-web-components/anypoint-collapse
cd anypoint-collapse
npm install
```

### 本地运行演示

```sh
npm start
```

### 运行测试

```sh
npm test
```

## 常见问题

### @anypoint-web-components/anypoint-collapse 是什么？

铁-相撞元素的现代端口\. 它形成了一个可折叠的内容块\.

### 如何安装 @anypoint-web-components/anypoint-collapse？

在项目目录运行 npm install @anypoint-web-components/anypoint-collapse，或使用 pnpm add / yarn add / bun add。

### @anypoint-web-components/anypoint-collapse 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/anypoint-web-components\_\_anypoint-collapse 是否存在。

### @anypoint-web-components/anypoint-collapse 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @anypoint-web-components/anypoint-collapse 可以商用吗？

@anypoint-web-components/anypoint-collapse 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @anypoint-web-components/anypoint-collapse 的下载量有多少？

根据 npm 官方下载统计，@anypoint-web-components/anypoint-collapse 在 2026/10/06 – 2026/11/04 这 30 天内被下载 3,082 次，日均约 103 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @anypoint-web-components/anypoint-collapse 还在维护吗？

最新版本 0\.1\.3 发布于 2021/10/16（5 年前）；至今共发布 4 个版本，其中过去 12 个月发布了 0 个；首次发布于 2020/06/16。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

