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中文網其他相關文章!

選擇Python還是JavaScript應基於職業發展、學習曲線和生態系統:1)職業發展:Python適合數據科學和後端開發,JavaScript適合前端和全棧開發。 2)學習曲線:Python語法簡潔,適合初學者;JavaScript語法靈活。 3)生態系統:Python有豐富的科學計算庫,JavaScript有強大的前端框架。

JavaScript框架的強大之處在於簡化開發、提升用戶體驗和應用性能。選擇框架時應考慮:1.項目規模和復雜度,2.團隊經驗,3.生態系統和社區支持。

引言我知道你可能會覺得奇怪,JavaScript、C 和瀏覽器之間到底有什麼關係?它們之間看似毫無關聯,但實際上,它們在現代網絡開發中扮演著非常重要的角色。今天我們就來深入探討一下這三者之間的緊密聯繫。通過這篇文章,你將了解到JavaScript如何在瀏覽器中運行,C 在瀏覽器引擎中的作用,以及它們如何共同推動網頁的渲染和交互。 JavaScript與瀏覽器的關係我們都知道,JavaScript是前端開發的核心語言,它直接在瀏覽器中運行,讓網頁變得生動有趣。你是否曾經想過,為什麼JavaScr

Node.js擅長於高效I/O,這在很大程度上要歸功於流。 流媒體匯總處理數據,避免內存過載 - 大型文件,網絡任務和實時應用程序的理想。將流與打字稿的類型安全結合起來創建POWE

Python和JavaScript在性能和效率方面的差異主要體現在:1)Python作為解釋型語言,運行速度較慢,但開發效率高,適合快速原型開發;2)JavaScript在瀏覽器中受限於單線程,但在Node.js中可利用多線程和異步I/O提升性能,兩者在實際項目中各有優勢。

JavaScript起源於1995年,由布蘭登·艾克創造,實現語言為C語言。 1.C語言為JavaScript提供了高性能和系統級編程能力。 2.JavaScript的內存管理和性能優化依賴於C語言。 3.C語言的跨平台特性幫助JavaScript在不同操作系統上高效運行。

JavaScript在瀏覽器和Node.js環境中運行,依賴JavaScript引擎解析和執行代碼。 1)解析階段生成抽象語法樹(AST);2)編譯階段將AST轉換為字節碼或機器碼;3)執行階段執行編譯後的代碼。

Python和JavaScript的未來趨勢包括:1.Python將鞏固在科學計算和AI領域的地位,2.JavaScript將推動Web技術發展,3.跨平台開發將成為熱門,4.性能優化將是重點。兩者都將繼續在各自領域擴展應用場景,並在性能上有更多突破。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

Dreamweaver Mac版
視覺化網頁開發工具

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)