jQuery和jQuery Mobile之间的区别?(Difference between jQuery and jQuery Mobile?)

编程入门 行业动态 更新时间:2024-10-27 08:25:20
jQuery和jQuery Mobile之间的区别?(Difference between jQuery and jQuery Mobile?)

我是移动Web开发的新手,我刚刚用PhoneGap制作了一个移动应用程序,经常使用jQuery。

但是,自然会出现一些关于我如何格式化的事情和他们实际出现在我正在测试的移动设备屏幕上的方式的毛刺,并且在尝试这些工作时,我偶然发现了许多建议,以便通过使用jQuery手机。

现在这让我很困惑 - jQuery没有格式化的滚动。 这只是我初学者对移动CSS的一些知识,导致了这些问题。

那么jQuery手机究竟做了什么,它与普通的jQuery有什么不同呢? 如果我已经知道jQuery,对我来说会是什么新鲜事?

I'm new to mobile web development, and I just made a mobile-app with PhoneGap, employing frequent use of jQuery.

But there were naturally a couple of glitches related to how I formatted things and the way they actually appeared on the mobile device screens I was testing with, and in trying to work these out I stumbled across many suggestions to make things easier on myself by using jQuery mobile.

Now this confuses me-- jQuery had no roll in formatting. That was just my beginner's level knowledge of mobile CSS that caused the problems.

So what exactly does jQuery mobile do, and how is it different from ordinary jQuery? If I already know jQuery, what's going to be new to me?

最满意答案

jQuery纯粹是为了简化和标准化跨浏览器的脚本。 它专注于低级的东西:创建元素,操纵DOM,管理属性,执行HTTP请求等。

jQueryUI是一组建立在jQuery之上的用户界面组件和功能(即需要使用jQuery):按钮,对话框,滑块,选项卡,更高级的动画,拖放功能。

jQuery和jQueryUI都被设计为“添加”到您的网站(桌面或移动) - 如果要添加特定功能,jQuery或jQueryUI可能有帮助。

但是, jQuery Mobile是一个完整的框架。 这是您的移动网站的起点。 它需要jQuery并利用jQuery和jQueryUI的功能来提供用于构建移动设备的网站的UI组件和API功能。 您仍然可以尽可能多地使用它,但如果您放心,jQuery Mobile 可以以适合移动设备的方式控制整个视口。

另一个主要区别是jQuery和jQueryUI旨在成为HTML和CSS之上的一层。 您应该能够单独留下您的标记,并通过jQuery进行增强。 但是,jQuery Mobile提供了定义要使用HTML单独显示组件的位置的方法 - 例如(来自jQuery Mobile站点):

<ul data-role="listview" data-inset="true" data-filter="true"> <li><a href="#">Acura</a></li> <li><a href="#">Audi</a></li> <li><a href="#">BMW</a></li> <li><a href="#">Cadillac</a></li> <li><a href="#">Ferrari</a></li> </ul>

data-role属性告诉jQuery Mobile将此列表转换为适合移动设备的UI组件,并且data-inset和data-filter属性设置其属性,而无需编写单行JavaScript。 另一方面,jQueryUI组件通常通过编写几行JavaScript来实例化DOM中的组件来创建。

jQuery is purely designed to simplify and standardise scripting across browsers. It focuses on the low-level stuff: creating elements, manipulating the DOM, managing attributes, performing HTTP requests, etc.

jQueryUI is a set of user interface components & features built on top of jQuery (i.e. it needs jQuery to work): buttons, dialog boxes, sliders, tabs, more advanced animations, drag/drop functionality.

jQuery and jQueryUI are both designed to be 'added' to your site (desktop or mobile) - if you want to add a particular feature, jQuery or jQueryUI might be able to help.

jQuery Mobile, however, is a full framework. It's intended to be your starting point for a mobile site. It requires jQuery and makes use of features of both jQuery and jQueryUI to provide both UI components and API features for building mobile-friendly sites. You can still use as much or as little of it as you like, but jQuery Mobile can control the whole viewport in a mobile-friendly way if you let it.

Another major difference is that jQuery and jQueryUI aim to be a layer on top of your HTML and CSS. You should be able to just leave your markup alone and enhance it with jQuery. However, jQuery Mobile provides ways to define where you want components to appear using HTML alone - e.g. (from the jQuery Mobile site):

<ul data-role="listview" data-inset="true" data-filter="true"> <li><a href="#">Acura</a></li> <li><a href="#">Audi</a></li> <li><a href="#">BMW</a></li> <li><a href="#">Cadillac</a></li> <li><a href="#">Ferrari</a></li> </ul>

The data-role attribute tells jQuery Mobile to turn this list into a mobile-friendly UI component and the data-inset and data-filter attributes set properties of that - without writing a single line of JavaScript. jQueryUI components, on the other hand, are normally created by writing a few lines of JavaScript to instantiate the component in the DOM.

更多推荐

本文发布于:2023-07-22 14:06:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1220589.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区别   jQuery   Mobile   Difference

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!