phonegap+jquerymobile:页面跳转出现白屏的解决方案

本文针对使用PhoneGap结合jQuery Mobile开发Android应用时遇到的页面跳转白屏现象,提供了三种解决方法:一是调整CSS样式实现,二是修改jQuery Mobile默认过渡效果,三是禁用Android硬件加速。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用phonegap+jquerymobile开发android程序时,不同的page跳转出现了白屏,很难看,也影响了用户体验。

1.对此jquerymobile官方给出的解决方案是:

Important: Some platforms currently have issues with transitions. We are working on a solution to solve the problem for everyone. If you are experiencing flickers and flashes during or at the end of a transition we suggest the following workaround.
Please note that this workaround should be throughly tested on the target platform before deployment. This workaround is known to cause performance issues, and browser crashes on some platforms especially Android. Add the following code to your custom css.

.ui-page { -webkit-backface-visibility: hidden; }


http://jquerymobile.com/demos/1.2.0/docs/pages/page-transitions.html


2.如果不行,或者出现其他问题,可以尝试一下

// 加载jQuery
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>

// 加载一段js(见下文)
<script type="text/javascript" src="mobile/js/mobile-site-custom-jqm-defaults.js"></script>

// 加载 jQuery Mobile
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>

// 加载你自己的<span class="wp_keywordlink"><a target=_blank href="http://www.xuebuyuan.com/" title="代码" target="_blank">代码</a></span>
<script type="text/javascript" src="mobile/js/script.js"></script>
其中mobile-site-custom-jqm-defaults.js内容如下

$(document).bind("mobileinit", function(){
  $.extend(  $.mobile , {
   defaultPageTransition: 'none'
  });
});

3.如果上方法都不可行,还可以尝试一下关闭android的硬件加速

在androidmenifest.xml中设置

<application
            android:label="@string/app_name0"
            android:allowClearUserData="false"
            android:icon="@drawable/logo"
            android:logo="@drawable/logo"
            android:name="com.xx.xx"
            android:hardwareAccelerated="false">
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值