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. }); 
相關文章
相關標籤/搜索