搜尋套件、儲存庫與 APP 分類

套件詳情v4.0.0+1

dquery

DQuery 是 jQuery 在 Dart 中的移植版本。

Web
近 30 天下載
379
喜歡數
2
Pub 分數
105

安裝套件

flutter pub add dquery

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

DQuery 是 jQuery 的 Dart 實作,專為使用 Flutter 建構的 Web 應用帶來熟悉的 DOM 操作與事件處理功能。它讓開發者能以類似 jQuery 的語法來選擇、遍歷及修改 HTML 元素,從而簡化客戶端 Web 開發。DQuery 支援常見的操作,如元素選擇、CSS 操作、事件繫結以及類似 AJAX 的請求,非常適合增強動態 Web 界面。它僅在 Web 平台上運行,並利用 Dart 與 JavaScript 的互操作性。

適用情境

  • 簡化 Flutter Web 應用中的 DOM 操作
  • 向網頁使用者介面添加互動行為
  • 將基於 jQuery 的邏輯遷移到 Dart
  • 增強Flutter專案中的Web特定功能

主要特色

  • 熟悉的 jQuery 風格語法
  • DOM 選擇和遍歷
  • 事件處理和委託
  • CSS操作
  • AJAX 類請求支援

適合對象

  • 面向 Web 平台的 Flutter 開發人員
  • 熟悉 jQuery 的團隊
  • 需要輕量級 DOM 互動的專案
  • 面向網路的 Flutter 應用

使用建議

  • 僅限網頁平台
  • 不適用於行動裝置或桌面端
  • 可能引入 JavaScript 互操作開銷
  • 比起複雜的狀態管理,更適合簡單的 DOM 作業

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

DQuery

DQuery is a porting of jQuery in Dart.

Install from Dart Pub Repository

Include the following in your pubspec.yaml:

dependencies:
  dquery: any

Then run the Pub Package Manager in Dart Editor (Tool > Pub Install). If you are using a different editor, run the command (comes with the Dart SDK):

pub install

Usage

You can create a query object by selector. With context provided, the query will be based on different element.

// selects all elements containing 'active' in CSS class
ElementQuery $elems = $('.active');

// selects all descendant elements of div containing 'active' in CSS class
ElementQuery $elems = $('.active', div);

It implements List.

$('.active')[0];
$('.active').isEmpty;
for (Element e in $('.active')) { ... }

Create another query object with traversing API, including find, closest, parent, children.

$('.active').closest('ul');
$('#myDiv').find('a.btn');

Manipulate selected elements.

$('.active').removeClass('active');
$('.fade').hide();

Register event handlers on queried elements, or trigger an event by API.

$('#myBtn').on('click', (QueryEvent e) {
	...
});
$('#myBtn').trigger('click', data: 'my data');

There are query objects of Document and Window too.

Query $doc = $document();
Query $win = $window();

Check the API reference for more features.

Comparison to jQuery

See here.

Notes to Contributors

Test and Debug

You are welcome to submit bugs and feature requests. Or even better if you can fix or implement them!

Fork DQuery

If you'd like to contribute back to the core, you can fork this repository and send us a pull request, when it is ready.

Please be aware that one of Rikulo's design goals is to keep the sphere of API as neat and consistency as possible. Strong enhancement always demands greater consensus.

If you are new to Git or GitHub, please read this guide first.

Who Uses

  • Quire - a simple, collaborative, multi-level task management tool.
  • Keikai - a sophisticated spreadsheet for big data

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案