@anypoint-web-components/anypoint-menu-mixin

中文文档
1.1.9发布于 2021/08/20Apache-2.0ESM + CJS近 30 天下载 3261

与ES6等相通的"铁选"口. 管理可以选择的元素列表.

中文使用文档
文档目录8 节
  1. MenuMixin 财务报告和审定财务报表 MenubarMixin
  2. 使用量
  3. 安装
  4. 在 LitElement 模板中
  5. 无障碍
  6. 发展
  7. 本地运行演示
  8. 运行测试

Published on NPM

Build Status

Published on webcomponents.org

任意点菜单混合

这是港口 铁门行为 与LitElement和ES6类合作,最初由Polymer团队开发.

MenuMixin 财务报告和审定财务报表 MenubarMixin

MenuMixin 财务报告和审定财务报表 MenubarMixin 执行可访问菜单和菜单条混合. 混合剂延伸 MultiSelectableMixin 从 @anypoint-web-components/anypoint-selector 软件包.

使用量

安装

npm install @anypoint-web-components/anypoint-menu-mixin --save

在 LitElement 模板中

import { LitElement, html } from 'lit-element';
import { MenuMixin } from '@anypoint-web-components/anypoint-menu-mixin';

class SimpleMenu extends MenuMixin(LitElement) {
  static get styles() {
    return css`
    :host > ::slotted(.selected) {
      color: white;
      background-color: #2196F3;
    }

    :host > ::slotted([disabled]) {
      pointer-events: none;
    }`;
  }

  render() {
    return html`<slot></slot>`;
  }
}
window.customElements.define('simple-menu', SimpleMenu);

然后,在您的 HTML 中:

<html>
  <head>
    <script type="module" src="./simple-menu.js"></script>
    <style>
    /* Overrides component's internal styling */
    simple-menu .selected {
      background-color: blue;
      color: white;
    }
    </style>
  </head>
  <body>
    <simple-menu>
      <div>Item 0</div>
      <div>Item 1</div>
      <div>Item 2</div>
      <div>Item 3</div>
      <div>Item 4</div>
    </simple-menu>
    <script>
    {
      document.querySelector('simple-menu').onselect = (e) => {
        console.log(e.detail.value);
      };
    }
    </script>
  </body>
</html>

无障碍

混音符设置了"菜单"和"菜单"等执行元素的默认角色. 混音可以用于不同的上下文. 那你可能想把角色换成别的东西 如果新角色要求孩子拥有"aria-set"属性,那么额外设定 useAriaSelected 属性,所以元素将处理选择.

<tabs-implementation role="tablist" useariaselected>
  <button role="tab">Tab #1</button>
  <button role="tab">Tab #2</button>
  <button role="tab">Tab #3</button>
</tabs-implementation>

发展

git clone https://github.com/anypoint-web-components/anypoint-menu-mixin
cd anypoint-menu-mixin
npm install

本地运行演示

npm start

运行测试

npm test

版本与发布记录

@anypoint-web-components/anypoint-menu-mixin 共发布 13 个版本,首次发布于 2019/08/04;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.9latest2021/08/205 年前
1.1.82020/11/265 年前
1.1.72020/09/286 年前
1.1.62020/06/276 年前
1.1.52020/06/266 年前
1.1.42020/06/256 年前

关于 @anypoint-web-components/anypoint-menu-mixin 的常见问题

@anypoint-web-components/anypoint-menu-mixin 是什么?

与ES6等相通的"铁选"口. 管理可以选择的元素列表.

如何安装 @anypoint-web-components/anypoint-menu-mixin?

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

@anypoint-web-components/anypoint-menu-mixin 支持 TypeScript 吗?

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

@anypoint-web-components/anypoint-menu-mixin 支持 ESM 还是 CommonJS?

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

@anypoint-web-components/anypoint-menu-mixin 可以商用吗?

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

@anypoint-web-components/anypoint-menu-mixin 的下载量有多少?

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

@anypoint-web-components/anypoint-menu-mixin 还在维护吗?

最新版本 1.1.9 发布于 2021/08/20(5 年前);至今共发布 13 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/08/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。