Lit

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

Github星跟蹤圖

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

概覽

名稱與所有者lit/lit
主編程語言TypeScript
編程語言TypeScript (語言數: 6)
平台Cross-platform, Web browsers
許可證BSD 3-Clause "New" or "Revised" License
發布數506
最新版本名稱@lit-labs/ssr-react@0.3.0 (發布於 2024-04-25 19:50:58)
第一版名稱0.6.0 (發布於 )
創建於2017-06-29 16:27:16
推送於2024-05-13 15:48:12
最后一次提交
星數17.6k
關注者數208
派生數878
提交數2.5k
已啟用問題?
問題數1827
打開的問題數384
拉請求數1737
打開的拉請求數113
關閉的拉請求數496
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

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.

去到頂部