GitHub
(原名PDQuickUI,从0.6.0版本开始更名为QuickUI)
QuickUI是一个源自PDRenderKit的前端渲染框架,专注于增强前端框架功能。
通过集成虚拟DOM,重写渲染逻辑,提高渲染效率,实现更快的数据观察和自动更新。
该项目从 PDRenderKit 中删除了原型扩展,以确保兼容性和性能,使其适合复杂的应用程序。
它提供模块和非模块版本,并将 PDRenderKit 中的许可证从 GPL-3.0 更改为 MIT。
特征
- 清晰的架构:将UI与数据逻辑分离,使其更易于维护。
- 代码简洁:减少冗余代码,增强可读性。
- 自动渲染:自动监控数据变化和更新,最大限度地减少手动操作。
- 轻量级:在小于 20kb 的文件大小内保持完整功能。
安装
-
从 npm 安装
npm i @pardnchiu/quickui
-
包含来自 CDN
-
直接包含QuickUI
<!-- Version 0.6.0 and above --> <script src="https://cdn.jsdelivr.net/npm/@pardnchiu/quickui@%5BVERSION%5D/dist/QuickUI.js"></script> <!-- Version 0.5.4 and below --> <script src="https://cdn.jsdelivr.net/npm/pdquickui@%5BVERSION%5D/dist/PDQuickUI.js"></script>
-
模块版本
// Version 0.6.0 and above import { QUI } from "https://cdn.jsdelivr.net/npm/@pardnchiu/quickui@[VERSION]/dist/QuickUI.esm.js"; // Version 0.5.4 and below import { QUI } from "https://cdn.jsdelivr.net/npm/pdquickui@[VERSION]/dist/PDQuickUI.module.js";
-
用法
-
初始化 QUI
const app = new QUI({ id: "", // Specify rendering element data: { // Custom DATA }, event: { // Custom EVENT }, when: { before_render: function () { // Stop rendering }, rendered: function () { // Rendered }, before_update: function () { // Stop updating }, updated: function () { // Updated }, before_destroy: function () { // Stop destruction }, destroyed: function () { // Destroyed } } });
概述
自动渲染:检测到数据更改时自动重新加载。
属性概述
Attribute | Description |
---|---|
{{value}} | Inserts text into HTML tags and automatically updates with data changes. |
:path | Used with the temp tag to load HTML fragments from external files into the current page. |
:html | Replaces the element's innerHTML with text. |
:for | Supports formats like item in items, (item, index) in items, (key, value) in object. Iterates over data collections to generate corresponding HTML elements. |
:if :else-if :elif :else |
Displays or hides elements based on specified conditions, enabling branching logic. |
:model | Binds data to form elements (e.g., input), updating data automatically when input changes. |
:hide | Hides elements based on specific conditions. |
:animation | Specifies transition effects for elements, such as fade-in or expand, to enhance user experience. |
:mask | Controls block loading animations, supporting `true |
:[attr] | Sets element attributes, such as ID, class, image source, etc. Examples: :id/:class/:src/:alt/:href... |
:[css] | Sets element CSS, such as margin, padding, etc. Examples: :background-color, :opacity, :margin, :top, :position... |
@[event] | Adds event listeners that trigger specified actions upon activation. Examples: @click/@input/@mousedown... |
文本替换
{{价值}}
-
index.html
npm i @pardnchiu/quickui
-
结果
<!-- Version 0.6.0 and above --> <script src="https://cdn.jsdelivr.net/npm/@pardnchiu/quickui@%5BVERSION%5D/dist/QuickUI.js"></script> <!-- Version 0.5.4 and below --> <script src="https://cdn.jsdelivr.net/npm/pdquickui@%5BVERSION%5D/dist/PDQuickUI.js"></script>
:html
-
index.html
// Version 0.6.0 and above import { QUI } from "https://cdn.jsdelivr.net/npm/@pardnchiu/quickui@[VERSION]/dist/QuickUI.esm.js"; // Version 0.5.4 and below import { QUI } from "https://cdn.jsdelivr.net/npm/pdquickui@[VERSION]/dist/PDQuickUI.module.js";
-
结果
const app = new QUI({ id: "", // Specify rendering element data: { // Custom DATA }, event: { // Custom EVENT }, when: { before_render: function () { // Stop rendering }, rendered: function () { // Rendered }, before_update: function () { // Stop updating }, updated: function () { // Updated }, before_destroy: function () { // Stop destruction }, destroyed: function () { // Destroyed } } });
插入块
> [!注意]
>确保在测试时禁用浏览器中的本地文件限制或使用实时服务器。
:小路
-
test.html
<h1 id="title">{{ title }}</h1> const app = new QUI({ id: "app", data: { title: "test" } });
-
index.html
<h1 id="test">test</h1>
-
结果
const app = new QUI({ id: "app", data: { html: "<b>innerHtml</b>" } });
循环渲染
:为了
-
index.html
<b>innerHtml</b>
-
结果
<h1 id="path-heading">path heading</h1> <p>path content</p>
-
结果
const app = new QUI({ id: "app" });
条件渲染
-
index.html
<h1 id="path-heading">path heading</h1> <p>path content</p>
-
结果:标题 = 1
- {{ item }} {{ CALC(index + 1) }}
-
结果:heading = null && isH2 = true
Nest loop
-
index.html
-
{{ key }}: {{ val.name }}
-
{{ item.name }}
- {{ CALC(index1 + 1) }}. {{ item1.name }} - ${{ item1.price }}
-
{{ item.name }}
-
{{ key }}: {{ val.name }}
-
结果:标题 = 3 && isH2 = null
- food: Food
- Snacks
- 1. Potato Chips -
- 2. Chocolate -
- Beverages
- 1. Juice -
- 2. Tea -
- Snacks
- home: Home
- Furniture
- 1. Sofa - 0
- 2. Table - 0
- Decorations
- 1. Picture Frame -
- 2. Vase -
- Furniture
- food: Food
-
结果:heading = null && isH2 = null
<h1 id="title-heading">{{ title }} {{ heading }}</h1> <h2 id="title-heading">{{ title }} {{ heading }}</h2> <h3 id="title-heading">{{ title }} {{ heading }}</h3> <h4 id="title-heading">{{ title }} {{ heading }}</h4> const app = new QUI({ id: "app", data: { heading: [Number|null], isH2: [Boolean|null], title: "test" } });
模板渲染
-
index.html
<h1 id="test">test 1</h1>
-
结果
<h2 id="test">test </h2>
绑定
<h3 id="test">test 3</h3>
活动
<h4 id="test">test </h4>
CSS
> [!注意]
>支持使用:[CSS属性]进行简单设置,直接将数据绑定到样式属性。
-
index.html
const test = new QUI({ id: "app", data: { hint: "hint 123", title: "test 123" }, render: () => { return ` "{{ hint }}", h1 { style: "background: red;", children: [ "{{ title }}" ] }` } })
-
结果:
hint 123 <h1 id="test">test 123</h1>
功能
长度()
-
index.html
test const app = new QUI({ id: "app", data: { password: null, }, event: { show: function(e){ alert("Password:", app.data.password); } } });
-
结果
test const app = new QUI({ id: "app", event: { test: function(e){ alert(e.target.innerText + " clicked"); } } });
计算()
-
index.html
test const app = new QUI({ id: "app", data: { width: "100px", color: "red" } });
-
结果
test
上() / 下()
-
index.html
<p>Total: {{ LENGTH(array) }}</p> const app = new QUI({ id: "app", data: { array: [1, 2, 3, 4] } });
-
结果
<p>Total: 4</p>
日期(数字,格式)
-
index.html
<p>calc: {{ CALC(num * 10) }}</p> const app = new QUI({ id: "app", data: { num: 1 } });
-
结果
<p>calc: 10</p>
延迟加载
:延迟加载
-
index.html
<p>{{ UPPER(test1) }} {{ LOWER(test2) }}</p> const app = new QUI({ id: "app", data: { test1: "upper", test2: "LOWER" } });
-
结果
<p>UPPER lower</p>
SVG 替换
-
测试.svg
<p>{{ DATE(now, YYYY-MM-DD hh:mm:ss) }}</p> const app = new QUI({ id: "app", data: { now: Math.floor(Date.now() / 1000) } });
-
index.html
<p>2024-08-17 03:40:47</p>
-
结果
<img src="/static/imghwm/default1.png" data-src="test.jpg" class="lazy" alt="QuickUI:轻量级前端框架" > const app = new QUI({ id: "app", data: { image: "test.jpg" }, option: { lazyload: true // Enable image lazy loading: true|false (default: true) } });
i18n
> [!注意]
>如果format是对象,则直接配置多语言内容。
>如果格式是字符串,则通过 fetch 动态加载语言文件。
-
en.json
<img src="/static/imghwm/default1.png" data-src="test.jpg" class="lazy" alt="QuickUI:轻量级前端框架" >
-
index.html
-
结果 i18nLang = zh
const app = new QUI({ id: "app", data: { svg: "test.svg", }, option: { svg: true // Enable SVG file transformation: true|false (default: true) } });
-
结果 i18nLang = en
生命周期挂钩
{ "greeting": "Hello", "username": "Username" }
数据检索
npm i @pardnchiu/quickui
创作者
邱敬帏 Pardn Chiu
执照
此项目已获得专有许可证许可。
您只能根据最终用户许可协议 (EULA) 中指定的条款使用、安装和运行此软件。
©️ 2024 邱敬帏 Pardn Chiu
以上是QuickUI:轻量级前端框架的详细内容。更多信息请关注PHP中文网其他相关文章!

JavaScript字符串替换方法详解及常见问题解答 本文将探讨两种在JavaScript中替换字符串字符的方法:在JavaScript代码内部替换和在网页HTML内部替换。 在JavaScript代码内部替换字符串 最直接的方法是使用replace()方法: str = str.replace("find","replace"); 该方法仅替换第一个匹配项。要替换所有匹配项,需使用正则表达式并添加全局标志g: str = str.replace(/fi

因此,在这里,您准备好了解所有称为Ajax的东西。但是,到底是什么? AJAX一词是指用于创建动态,交互式Web内容的一系列宽松的技术。 Ajax一词,最初由Jesse J创造

10款趣味横生的jQuery游戏插件,让您的网站更具吸引力,提升用户粘性!虽然Flash仍然是开发休闲网页游戏的最佳软件,但jQuery也能创造出令人惊喜的效果,虽然无法与纯动作Flash游戏媲美,但在某些情况下,您也能在浏览器中获得意想不到的乐趣。 jQuery井字棋游戏 游戏编程的“Hello world”,现在有了jQuery版本。 源码 jQuery疯狂填词游戏 这是一个填空游戏,由于不知道单词的上下文,可能会产生一些古怪的结果。 源码 jQuery扫雷游戏

本教程演示了如何使用jQuery创建迷人的视差背景效果。 我们将构建一个带有分层图像的标题横幅,从而创造出令人惊叹的视觉深度。 更新的插件可与JQuery 1.6.4及更高版本一起使用。 下载

Matter.js是一个用JavaScript编写的2D刚体物理引擎。此库可以帮助您轻松地在浏览器中模拟2D物理。它提供了许多功能,例如创建刚体并为其分配质量、面积或密度等物理属性的能力。您还可以模拟不同类型的碰撞和力,例如重力摩擦力。 Matter.js支持所有主流浏览器。此外,它也适用于移动设备,因为它可以检测触摸并具有响应能力。所有这些功能都使其值得您投入时间学习如何使用该引擎,因为这样您就可以轻松创建基于物理的2D游戏或模拟。在本教程中,我将介绍此库的基础知识,包括其安装和用法,并提供一

本文演示了如何使用jQuery和ajax自动每5秒自动刷新DIV的内容。 该示例从RSS提要中获取并显示了最新的博客文章以及最后的刷新时间戳。 加载图像是选择

本文讨论了在浏览器中优化JavaScript性能的策略,重点是减少执行时间并最大程度地减少对页面负载速度的影响。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

Dreamweaver Mac版
视觉化网页开发工具

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

SublimeText3汉化版
中文版,非常好用

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),