From HTML

优质
小牛编辑
128浏览
2023-12-01

描述 (Description)

要打开和关闭面板,请分别将open-panelclose-panel类添加到任何HTML元素。 默认情况下,当您的应用有两个面板时, left面板将打开/关闭。 您可以通过添加data-panel = "left"属性来指定应打开/关闭data-panel = "left"

例子 (Example)

以下示例演示了在Framework7中使用打开和关闭面板。

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1, 
         maximum-scale = 1, minimum-scale = 1, user-scalable = no, minimal-ui" />
      <meta name = "apple-mobile-web-app-capable" content = "yes" />
      <meta name = "apple-mobile-web-app-status-bar-style" content = "black" />
      <title>Open and Close Panels</title>
      <link rel = "stylesheet" 
         href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.min.css" />
      <link rel = "stylesheet" 
         href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.colors.min.css" />
   </head>
   <body>
      <div class = "panel-overlay"></div>
      <div class = "panel panel-left panel-reveal">
         <div class = "content-block">
            <p>Left Panel content</p>
            <p><a href = "#" data-panel = "right" class = "open-panel">Open Right Panel</a></p>
            <p><a href = "#" class = "close-panel">Close me</a></p>
         </div>
      </div>
      <div class = "panel panel-right panel-cover">
         <div class = "content-block">
            <p>Right Panel content</p>
            <p><a href = "#" data-panel = "left" class = "open-panel">Open Left Panel</a></p>
            <p><a href = "#" class = "close-panel">Close me</a></p>
         </div>
      </div>
      <div class = "views">
         <div class = "view view-main">
            <div class = "pages">
               <div data-page = "home" class = "page navbar-fixed">
                  <div class = "navbar">
                     <div class = "navbar-inner">
                        <div class = "left"> </div>
                        <div class = "center">Side Panels</div>
                        <div class = "right"> </div>
                     </div>
                  </div>
                  <div class = "page-content">
                     <div class = "content-block">
                        <p> <a href = "#" class = "open-panel">Open Left Panel</a></p>
                        <p> <a href = "#" data-panel = "right" class = "open-panel">Open Right Panel</a></p>
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
      <script type = "text/javascript" 
         src = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/js/framework7.min.js"></script>
      <script>
         var myApp = new Framework7();
      </script>
   </body>
</html>

输出 (Output)

让我们执行以下步骤,看看上面给出的代码是如何工作的 -

  • 将上面给出的HTML代码保存为服务器根文件夹中的sidepanels_open_close_fromHTML.html文件。

  • 以http://localhost/sidepanels_open_close_fromHTML.html打开此HTML文件,输出显示如下。

  • 单击“ Open Left Panel链接时,此示例显示左侧面板,单击“ Open Right Panel链接时显示右侧面板。