jQuery Mobile 与 AngularJs 页面导航 [英] jQuery Mobile vs AngularJs page navigation

查看:24
本文介绍了jQuery Mobile 与 AngularJs 页面导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jQuery Mobile 和 AngularJS 开发一个混合移动应用程序.

I am developing a hybrid mobile app using jQuery Mobile and AngularJS.

我决定将两者混合用于以下目的:

I decided to use a mix of the two for the following:

  1. jQuery 移动版
    • 良好的用户界面功能
    • 不太重(例如与煎茶触控相比)
  • 良好的性能和资源管理(缓存、异步请求)
  • 个人经历

我几乎没有使用 jQuery Mobile 的经验,并且在我学习的过程中,我注意到两者的页面导航模型之间存在潜在冲突.

I have little to no experience with jQuery Mobile and, as I was learning, I noticed a potential conflict between the page navigation models of the two.

  1. 我应该只使用一个吗?
  2. 如果是,哪一个更适合我的需求?
  3. 这个设置有什么问题吗?

非常感谢.

推荐答案

您无法将它们相互比较.

You can't compare them to each other.

Angular.js(例如 Backbone、Ember)是 MV* 框架(用于 SPA),用于直接在客户端而不是服务器中呈现 html 模板/视图.所以你的前端现在有很多应用逻辑,这个框架是为了让你的生活更美好,编码这些.

Angular.js (like Backbone, Ember eg.) are MV* Frameworks (for SPA) which used to render html templates/views directly in the client instead of server. So you have a lot of application logic now in your frontend and this Frameworks are made to make your life better, coding this.

另一方面,jQuery Mobile 是一个纯小部件/插件库.AJAX 导航插件通过 AJAX 将页面(静态的,如 html)加载到 DOM 中.所以你必须以某种方式在服务器上预渲染这个页面.如果您开始使用 Angular 构建 SPA,那么使用 jQuery Mobile 的 AJAX 导航根本没有意义.(如果它是原生移动应用程序,您无论如何都没有服务器.)

jQuery Mobile on the other side is a pure widget/plugin library. The AJAX navigation plugin load pages (something static, like html) into the DOM via AJAX. So you have to pre-render this pages on the server somehow. If you started to build a SPA with Angular it doesn't make sense to use jQuery Mobile's AJAX navigation at all. (If it's a native mobile app you have no server anyway.)

当然,如果没有 UI 组件库,您将走不远,因此请使用您的选择之一(例如 jQM),但使用 Angular 的指令从 $(document) 开始在 DOM 元素上正确初始化插件/小部件.ready(...) 或 $(document).on( "pageload", ... ) 对您的 Angular 视图一无所知.看看以下项目:http://angular-ui.github.iohttps://github.com/angular-widgets/angular-jqm

Sure, you won't get far without an UI component library so use one of your choice (eg. jQM) but work with Angular's directives to init the plugins/widgets correctly on your DOM elements since a $(document).ready(...) or a $(document).on( "pageload", ... ) doesn't know anything about your Angular views. Take a look at following projects: http://angular-ui.github.io https://github.com/angular-widgets/angular-jqm

这篇关于jQuery Mobile 与 AngularJs 页面导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆