简体   繁体   English

如何呈现一个jquerymobile页面?

[英]How to render a jquerymobile page?

I have an PhoneGap Application which uses JQM. 我有一个使用JQM的PhoneGap应用程序。 To navigate I use a navbar-widget, which opens the requested page (There are 4 pages). 要导航,我使用navbar-widget,它将打开请求的页面(共有4页)。 The first time a page is accessed through this navigation it needs quite a while to show up (depending on the device between 6 and 10 sec). 第一次通过此导航访问页面时,它需要一段时间才能显示出来(取决于设备在6到10秒之间)。 I assume this is because of the rendering process of JQM. 我认为这是由于JQM的渲染过程所致。 Hence this behaviour is not exactly what I want, I wonder if I could render the pages manually the first time the application gets started (ie while showing a splash screen). 因此,这种行为并不完全是我想要的,我想知道是否可以在应用程序首次启动时(即在显示初始屏幕时)手动呈现页面。 Has anyone done something similar before or has someone an idea of how to start this rendering process manually? 有没有人做过类似的事情,或者有人知道如何手动启动此渲染过程?

I would presume from your question that you are using several HTML pages through navbar element. 根据您的问题,我认为您正在通过navbar元素使用多个HTML页面。

This is your first mistake. 这是您的第一个错误。 I hope this is not a big project for you cause you are going into the world of pain. 我希望这对您来说不是一个大项目,因为您将进入痛苦的世界。

First, you can prefetch jQuery Mobile pages, that will improve page change time, read more about it here . 首先,您可以预取jQuery Mobile页面,这将缩短页面更改时间, 在此处了解更多信息。 Unfortunately this solution has few problems, mainly sometime it will not work. 不幸的是,该解决方案几乎没有问题,主要是在某些时候它不起作用。

My best advice would be to change you app design. 我最好的建议是改变您的应用程序设计。 Your main navbar pages should be part of a single HTML file, it is also called a multipage template. 您的主要导航栏页面应该是单个HTML文件的一部分,也称为多页模板。 This is fastest solution but most resource hungry. 这是最快的解决方案,但大多数资源都很匮乏。 Also your pages should not be content heavy, it is a main jQuery Mobile app performance killer. 另外,您的页面不应内容繁重,它是jQuery Mobile应用程序性能的主要杀手。

I have to excellent articles for you that will help you build a faster jQuery Mobile app, take a look here and here . 我必须为您提供出色的文章,这些文章将帮助您构建更快的jQuery Mobile应用程序, 在这里这里看看。

If it is not to late I would advise switching to Sencha Touch. 如果还不晚,我建议您切换到Sencha Touch。 It will take some time to learn it (it has a completely different approach then jQuery Mobile) but in the end you will have a much faster app. 学习它会花费一些时间(它的方法与jQuery Mobile完全不同 ),但最终您将拥有一个更快的应用程序。 I am telling you this as a jQuery Mobile developer, not a Sencha Touch one. 我是作为jQuery Mobile开发人员而不是Sencha Touch开发人员告诉您的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM