jQuery Mobile - 内部和外部面板
描述
您可以通过在 href 属性中提供面板路径来显示内部和外部面板。
示例
以下示例描述了在 jQuery Mobile 框架中使用内部和外部面板。
<!DOCTYPE html> <html> <head> <title>External and Internal Panels</title> <meta name = "viewport" content = "width = device-width, initial-scale = 1"> <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script> <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> <script> $( document ).on( "pagecreate", function() { $( "body > [data-role = 'panel']" ).panel(); $( "body > [data-role = 'panel'] [data-role = 'listview']" ).listview(); }); $( document ).one( "pageshow", function() { $( "body > [data-role = 'header']" ).toolbar(); $( "body > [data-role = 'header'] [data-role = 'navbar']" ).navbar(); }); </script> </head> <body> <div data-role = "header" data-position = "fixed" data-theme = "a"> <h2>Header</h2> </div> <div data-role = "page"> <div role = "main" class = "ui-content"> <h2>This is first page.</h2> <a href = "#page_one" class = "ui-btn ui-btn-inline">Click here to open right panel</a> </div> <div data-role = "panel" id = "page_one" data-position = "right" data-display = "overlay" data-theme = "b"> <ul data-role = "listview"> <li data-icon = "delete"><a href = "#" data-rel = "close">Close</a></li> <li>New Zealand</li> <li>England</li> <li>South Africa</li> </ul> </div> <div data-role = "footer" data-position = "fixed"> <div data-role = "navbar"> <ul> <li><a href = "/jquery_mobile/src/jqm_external_internal_panel.html" class = "ui-btn-active">Page One</a></li> <li><a href = "/jquery_mobile/src/page2.html">Page Two</a></li> </ul> </div> </div> </div> </body> </html>
输出
让我们执行以下步骤,看看上面的代码是如何工作的 −
将上述 html 代码保存为服务器根文件夹中的 jqm_external_internal_panel.html 文件。
将此 HTML 文件打开为 http://localhost/jqm_external_internal_panel.html,将显示以下输出。