@advanced-rest-client/http-method-selector

中文文档
3.1.1发布于 2022/01/05Apache-2.0ESM + CJS近 30 天下载 3165

HTTP 方法选择器

中文使用文档
文档目录7 节
  1. 使用量
  2. 安装
  3. 在 html 文件内
  4. 在一个LitElement中
  5. 发展
  6. 本地运行演示
  7. 运行测试

http-method-selector 选择器

HTTP 方法选择器 。 显示带有常见的 http 方法的收音机按钮列表,以及使用不太常见但仍有效的方法的下拉.

它还允许定义自己的方法.

<http-method-selector method="POST" is-payload></http-method-selector>
<http-method-selector-mini method="PUT" is-payload></http-method-selector-mini>

Published on NPM

Tests and publishing

使用量

安装

npm install --save @advanced-rest-client/http-method-selector

在 html 文件内

<html>
  <head>
    <script type="module">
      import '@advanced-rest-client/http-method-selector/http-method-selector.js';
      import '@advanced-rest-client/http-method-selector/http-method-selector-mini.js';
    </script>
  </head>
  <body>
    <http-method-selector method="POST"></http-method-selector>
    <http-method-selector-mini method="PUT"></http-method-selector-mini>

    <script>
    {
      document.querySelector('http-method-selector').onmethod = (e) => {
        console.log(e.detail.value); // or e.target.method
      };
      document.querySelector('http-method-selector').onispayload = (e) => {
        if (e.detail.value) {
          console.log('Payload is allowed');
        } else {
          console.log('Payload is not allowed');
        }
      };
    }
    </script>
  </body>
</html>

在一个LitElement中

import { LitElement, html } from 'lit-element';
import '@advanced-rest-client/http-method-selector/http-method-selector.js';
import '@advanced-rest-client/http-method-selector/http-method-selector-mini.js';

class SampleElement extends PolymerElement {
  render() {
    return html`
    <http-method-selector
      method="POST"
      @method-changed="${this._verbHandler}"
      @ispayload-changed="${this._isPayloadHandler}"></http-method-selector>
    `;
  }

  _verbHandler(e) {
    this.httpMethod = e.target.method;
  }

  _isPayloadHandler(e) {
    this.payloadAllowed = e.detail.value;
  }
}
customElements.define('sample-element', SampleElement);

发展

git clone https://github.com/advanced-rest-client/http-method-selector
cd http-method-selector
npm install

本地运行演示

npm start

运行测试

npm test

版本与发布记录

@advanced-rest-client/http-method-selector 共发布 10 个版本,首次发布于 2019/02/27;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.1.1latest2022/01/054 年前
3.1.02021/03/125 年前
3.0.52019/11/216 年前
3.0.42019/10/117 年前
3.0.32019/10/027 年前
3.0.22019/09/177 年前

关于 @advanced-rest-client/http-method-selector 的常见问题

@advanced-rest-client/http-method-selector 是什么?

HTTP 方法选择器

如何安装 @advanced-rest-client/http-method-selector?

在项目目录运行 npm install @advanced-rest-client/http-method-selector,或使用 pnpm add / yarn add / bun add。

@advanced-rest-client/http-method-selector 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/advanced-rest-client__http-method-selector 是否存在。

@advanced-rest-client/http-method-selector 支持 ESM 还是 CommonJS?

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

@advanced-rest-client/http-method-selector 可以商用吗?

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

@advanced-rest-client/http-method-selector 的下载量有多少?

根据 npm 官方下载统计,@advanced-rest-client/http-method-selector 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,165 次,日均约 106 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@advanced-rest-client/http-method-selector 还在维护吗?

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