Lit

Lit 是一个用于构建快速、轻量级 web 组件的简单库。(Lit is a simple library for building fast, lightweight web components.)

Github stars Tracking Chart

lit-html

高效、有表现力、可扩展的 JavaScript HTML 模板。

文献资料

完整的文档可在 lit-html.polymer-project.org 中找到。

文件源代码位于 docs 资料夹中。 要自己构建网站,请参阅 docs/README.md 中的说明。

总览

lit-html 允许您使用 JavaScript 编写带有template literals(模板文本)HTML 模板

lit-html 模板是纯 JavaScript,将编写 HTML 的熟悉程度与 JavaScript 的功能结合在一起。 lit-html 负责有效地将模板呈现给 DOM,包括使用新值有效地更新 DOM。

import {html, render} from 'lit-html';
// This is a lit-html template function. It returns a lit-html template.
const helloTemplate = (name) => html`<div>Hello ${name}!</div>`;
// This renders <div>Hello Steve!</div> to the document body
render(helloTemplate('Steve'), document.body);
// This updates to <div>Hello Kevin!</div>, but only updates the ${name} part
render(helloTemplate('Kevin'), document.body);

lit-html 提供了两个主要 Exports:

  • html: 一个 JavaScript template tag(模板标记), 用于产生 TemplateResult,这是模板的容器,以及应填充模板的值。
  • render(): 将TemplateResult渲染到DOM容器(例如元素或影子根)的函数。

贡献

请参阅 CONTRIBUTING.md

Overview

Name With Ownerlit/lit
Primary LanguageTypeScript
Program languageTypeScript (Language Count: 6)
PlatformCross-platform, Web browsers
License:BSD 3-Clause "New" or "Revised" License
Release Count506
Last Release Name@lit-labs/ssr-react@0.3.0 (Posted on 2024-04-25 19:50:58)
First Release Name0.6.0 (Posted on )
Created At2017-06-29 16:27:16
Pushed At2024-05-05 18:00:15
Last Commit At
Stargazers Count17.6k
Watchers Count206
Fork Count876
Commits Count2.5k
Has Issues Enabled
Issues Count1825
Issue Open Count382
Pull Requests Count1736
Pull Requests Open Count113
Pull Requests Close Count495
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Simple. Fast. Web Components.

Build Status
Published on npm
Join our Discord
Mentioned in Awesome Lit

Lit is a simple library for building fast, lightweight web components.

At Lit's core is a boilerplate-killing component base class that provides reactive state, scoped styles, and a declarative template system that's tiny, fast and expressive.

Documentation

See the full documentation for Lit at lit.dev.

Additional documentation for developers looking to contribute or understand more about the project can be found in dev-docs.

npm

To install from npm:

npm i lit

Lit Monorepo

This is the monorepo for Lit packages.

lit 2.x source is available on the 2.x branch.
lit-html 1.x source is available on the lit-html-1.x branch.

Packages

Contributing to Lit

Lit is open source and we appreciate issue reports and pull requests. See CONTRIBUTING.md for more information.

Setting up the lit monorepo for development

Initialize repo:

git clone https://github.com/lit/lit.git
cd lit
npm ci

Build all packages:

npm run build

Test all packages:

npm run test

Run benchmarks for all packages:

npm run benchmarks

See individual package READMEs for details on developing for a specific package.

To the top