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

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

A HTTP method selector

原始使用文档
文档目录7 节
  1. Usage
  2. Installation
  3. In an html file
  4. In a LitElement
  5. Development
  6. Running the demo locally
  7. Running the tests

http-method-selector

A HTTP method selector. Displays list of radio buttons with common http methods and a dropdown with less common but still valid methods.

It also allows to define own method.

<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

Usage

Installation

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

In an html file

<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>

In a 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);

Development

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

Running the demo locally

npm start

Running the tests

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 是什么?

A HTTP method selector

如何安装 @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 和提交记录判断。