搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目