@8area8/domstrict 中文文档教程

发布于 6年前 浏览 23 项目主页 更新于 3年前

domstrict

“getElement”和“querySelector”方法的包装器。 返回元素或错误。

News

为 query 和 queryAll 添加 $base 参数。 Todo:创建测试并更新文档。

Installation

npm install @8area8/domstrict --save

Usage

Javascript

var get = require("@8area8/domstrict");
var $element = get.id("foo");
- Returns an HTMLElement OR throws an Error.

TypeScript

import Get from "@8area8/domstrict";
const $element = Get.queryAll(".bar");
- Returns an Array<Element> OR throws an Error.

API

class Get {
  static id(idName: string): HTMLElement;
  static class(idName: string): Element[];
  static query(selector: string): Element;
  static queryAll(selector: string): Element[];
}
/** Get an element by Id. Return the element or throw an Error. */
static id(idName: string): HTMLElement;
/** Get elements by class. Return an array or throw an Error. */
static class(className: string): Element[]
/** Get an element by query selector. Return the element or throw an Error. */
static query(selector: string): Element
/** Get an element by query selector. Return an array or throw an Error. */
static queryAll(selector: string): Element[]

Test

npm run test

domstrict

wrapper for the "getElement" and "querySelector" methods. Return the element or an error.

News

Add the $base parameter for query and queryAll. Todo: Create tests and update the documentation.

Installation

npm install @8area8/domstrict --save

Usage

Javascript

var get = require("@8area8/domstrict");
var $element = get.id("foo");
- Returns an HTMLElement OR throws an Error.

TypeScript

import Get from "@8area8/domstrict";
const $element = Get.queryAll(".bar");
- Returns an Array<Element> OR throws an Error.

API

class Get {
  static id(idName: string): HTMLElement;
  static class(idName: string): Element[];
  static query(selector: string): Element;
  static queryAll(selector: string): Element[];
}
/** Get an element by Id. Return the element or throw an Error. */
static id(idName: string): HTMLElement;
/** Get elements by class. Return an array or throw an Error. */
static class(className: string): Element[]
/** Get an element by query selector. Return the element or throw an Error. */
static query(selector: string): Element
/** Get an element by query selector. Return an array or throw an Error. */
static queryAll(selector: string): Element[]

Test

npm run test
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文