jQueryMobile新版中导航栏按钮消失的解决方法

最近将jQueryMobile的库更新到最新版后,发现之前用 jQueryMobile 写的一些东西, header 导航栏上的“后退”按钮通通不见了。这个功能挺贴心的,能够自动为你的 Web App 在不一样页面之间跳转的时候增长导航功能。因而翻 jQueryMobile 的官方文档,在不起眼的地方发现了这样一句话:javascript

jQuery Mobile has a feature to automatically create and append "back" buttons to any header, though it is disabled by default. This is primarily useful in chromeless installed applications, such as those running in a native app web view. The framework automatically generates a "back" button on a header when the page plugin’s addBackBtn option is true. This can also be set via markup if the page div has a data-add-back-btn="true" attribute.java

原来默认把这个功能是关闭。打开它很简单,须要在页面源代码的 page 中加上 data-add-back-btn="true" 。web

同时页面的代码中加上一句 js 代码便可:chrome

[javascript] view plain copy print ?
  1. $(document).bind("mobileinit"function() {  
  2. $.mobile.page.prototype.options.addBackBtn = true;  
  3. }); 
相关文章
相关标签/搜索