6个版本
| 0.0.1-alpha.5 | 2020年12月15日 |
|---|---|
| 0.0.1-alpha.4 | 2020年12月11日 |
| 0.0.1-alpha.3 | 2020年12月10日 |
| 0.0.1-alpha.1 | 2020年12月9日 |
#668 in WebAssembly
43KB
738 行
web-sys的jQuery-like API
jQuery已死,大家普遍认为应该使用像React这样的现代方法(或者在Rust/WASM世界中,使用Yew)。
web-sys-query 允许您使用熟悉的API将简单的jQuery应用程序移植到Rust/WASM,而不是复杂的 web-sys DOM API。
待办事项
- 文档和示例
- 单元测试
- AJAX
- ...
功能标志
serde-serialize:使用serde_derive启用对如FormData(默认禁用)等类型的Serialize和Deserialize支持。
API
属性
| jQuery:属性 | 文档 |
Element + Collection |
|---|---|---|
| .addClass() | add_class | |
| .attr() | attr, set_attr | |
| .hasClass() | has_class | |
| .html() | html, set_html | |
| .prop() | ||
| .removeAttr() | remove_attr | |
| .removeClass() | remove_class | |
| .removeProp() | ||
| .toggleClass() | toggle_class | |
| .val() | val, set_val, *_i32, *_f64 |
事件
| jQuery:属性 | 文档 |
Element + Collection |
|---|---|---|
| .blur() | blur, set_blur | |
| .change() | change, set_change | |
| .click() | click, set_click | |
| .contextmenu() | context_menu, set_context_menu | |
| .dblclick() | dbl_click, set_dbl_click | |
| .focus() | focus, set_focus | |
| .focusin() | ||
| .focusout() | ||
| .hover() | ||
| .keydown() | key_down, set_key_down | |
| .keypress() | key_press, set_key_press | |
| .keyup() | key_up, set_key_up | |
| .load() | ||
| .mousedown() | mouse_down, set_mouse_down | |
| .mouseenter() | mouse_enter, set_mouse_enter | |
| .mouseleave() | mouse_leave, set_mouse_leave | |
| .mousemove() | mouse_move, set_mouse_move | |
| .mouseout() | mouse_out, set_mouse_out | |
| .mouseover() | mouse_over, set_mouse_over | |
| .mouseup() | mouse_up, set_mouse_up | |
| .off() | set_off | |
| .on() | on, set_on | |
| .one() | ||
| .ready() | ||
| .resize() | resize, set_resize | |
| .scroll() | scroll, set_scroll | |
| .select() | select, set_select | |
| .submit() | submit, set_submit | |
| .trigger() | ||
| .triggerHandler() | ||
操作
| jQuery: 遍历 | 文档 |
Element + Collection |
|---|---|---|
| .after() | ||
| .append() | ||
| .appendTo() | ||
| .before() | ||
| .clone() | ||
| .css() | ||
| .detach() | ||
| .empty() | ||
| .height() | ||
| .innerHeight() | ||
| .innerWidth() | ||
| .insertAfter() | ||
| .insertBefore() | ||
| $.cssNumber | ||
| $.htmlPrefilter() | ||
| .offset() | ||
| .outerHeight() | ||
| .outerWidth() | ||
| .position() | ||
| .prepend() | ||
| .prependTo() | ||
| .remove() | ||
| .replaceAll() | ||
| .replaceWith() | ||
| .scrollLeft() | ||
| .scrollTop() | ||
| .text() | text, set_text | |
| .unwrap() | ||
| .width() | ||
| .wrap() | ||
| .wrapAll() | ||
| .wrapInner() |
遍历
| jQuery: 遍历 | 文档 |
Element + Collection |
|---|---|---|
| .add() | ||
| .addBack() | ||
| .children() | children | children |
| .closest() | closest | |
| .contents() | ||
| .each() | ||
| .end() | ||
| .eq() | ||
| .even() | ||
| .filter() | filter | |
| .find() | find | find |
| .first() | first | |
| .has() | has | |
| .is() | is | |
| .last() | last | |
| .map() | ||
| .next() | next | |
| .nextAll() | ||
| .nextUntil() | ||
| .not() | not | |
| .odd() | ||
| .offsetParent() | ||
| .parent() | parent | |
| .parents() | ||
| .parentsUntil() | ||
| .prev() | prev | |
| .prevAll() | ||
| .prevUntil() | ||
| .siblings() | ||
| .slice() |
辅助函数
| jQuery: 遍历 | 文档 |
Element + Collection |
|---|---|---|
| jQuery.param() | ||
| .serialize() | ||
| .serializeArray() | serialize_array, FormData |
版权和许可证
根据OpenBSD-ISC风格许可证授权,详情见LICENSE。
依赖
~6.5–9MB
~174K SLoC