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

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

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

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

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

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

- 包体积（解压后）：33.2 kB，22 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：未声明
- 运行依赖：4 个
- 首次发布：2019-06-23T03:57:43.117Z
- 最新版本发布：2021-10-15T11:03:55.902Z
- 近 30 天下载量：3262（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：13（近 12 个月 0 个）

## 中文简介

任何点列表项目

## 安装

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

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

## README

# 折旧

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

\====

本部分以"材料设计"文字字段为基础,并被调整为"任意点"平台组件.

任意点网络组件是允许在开源项目中构建任意点启用的UI的组件集.

菜单和列表视图中使用的列表项目 .

```html
<anypoint-item>Item</anypoint-item>
```

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

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

## 样式选项

该元素有两个内置主题:

-   材料设计 - 默认样式
-   任意点设计 - 通过添加启用 `legacy` 属性到元素.

OSS应用程序不应使用基于任意点的造型,因为它受到MuleSoft版权的保护. 此属性被保留给嵌入Anypoint平台的OSS应用程序.

## 使用量

### 安装

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

### 在 HTML 文件内

```html
<html>
  <head>
    <script type="module">
      import '@anypoint-web-components/anypoint-item/anypoint-item.js';
    </script>
  </head>
  <body>
    <div role="listbox" slot="content">
      <anypoint-item>
        Option 1
      </anypoint-item>
      <anypoint-item>
        Option 2
      </anypoint-item>
      <anypoint-item>
        Option 3
      </anypoint-item>
      <anypoint-item>
        <p>Paragraph as a child</p>
      </anypoint-item>
    </div>
  </body>
</html>
```

使用此元素为 `<anypoint-item-body>` 样式 `twoLine` 财务报告和审定财务报表 `threeLine` 页:1.

```html
<html>
  <head>
    <script type="module">
      import '@anypoint-web-components/anypoint-item/anypoint-item.js';
      import '@anypoint-web-components/anypoint-item/anypoint-item-body.js';
    </script>
  </head>
  <body>
    <div role="listbox" slot="content">
      <anypoint-item-body twoline>
        <div>Show your status</div>
        <div secondary>Your status is visible to everyone</div>
      </anypoint-item-body>
      <iron-icon icon="warning"></iron-icon>
    </div>
  </body>
</html>
```

用于 `anypoint-item` 作为链接,将其包裹在锚标签上. 自兹 `anypoint-item` ,您可能想要通过设置标签索引到 -1 来防止锚标接收焦点.

```html
<a href="https://domain.com/project" tabindex="-1">
  <anypoint-item raised>API Project</anypoint-item>
</a>
```

如果你对性能感兴趣,想使用 `anypoint-item` 在一个 `anypoint-listbox` 有很多东西,你可以使用本地的 `button` 与 `anypoint-item` 应用类(但您已正确包含共享样式) :

```javascript
import { LitElement, html, css } from 'lit-element';
import itemStyles from '@anypoint-web-components/anypoint-item/anypoint-item-shared-styles.js';

class SampleElement extends LitElement {
  get styles() {
    return [
      itemStyles,
      css`...`;
    ];
  }

  render() {
    return html`<style>${this.styles}</style>
    <anypoint-listbox>
      <button class="anypoint-item" role="option">Inbox</button>
      <button class="anypoint-item" role="option">Starred</button>
      <button class="anypoint-item" role="option">Sent mail</button>
    </anypoint-listbox>
    `;
  }
}
customElements.define('sample-element', SampleElement);
```

### 样式

见 [任何点-项目共享样式.js](https://npmcn.com/package/%40anypoint-web-components/anypoint-item/anypoint-item-shared-styles.js) 用于列出 CSS 变量.

### 无障碍

这个元素 `role="listitem"` 默认。 视使用情况而定,设置更为合适 `role="menuitem"`, (中文(简体) ), `role="menuitemcheckbox"` 或者说 `role="menuitemradio"`。 。 。 .

```html
<anypoint-item role="menuitemcheckbox">
  <anypoint-item-body>
    Show your status
  </anypoint-item-body>
  <paper-checkbox></paper-checkbox>
</anypoint-item>
```

## 发展

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

### 本地运行演示

```sh
npm start
```

### 运行测试

```sh
npm test
```

## 常见问题

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

任何点列表项目

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

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

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

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

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

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

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

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

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

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

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

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

