From HTML

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

描述 (Description)

您可以使用类和数据属性打开和关闭选取器模式。 使用open-picker类打开picker和close-picker类,将picker关闭到任何HTML元素。

例子 (Example)

以下示例显示在Framework7中从HTML中打开和关闭选择器模式 -

<!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>Picker Modal from HTML</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 = "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">Picker Modal from HTML</div>
                        <div class = "right"> <a href = "#" data-picker = ".my_page" class = "link open-picker">Picker</a></div>
                     </div>
                  </div>
                  <div class = "page-content">
                     <div class = "content-block">
                        <p><a href = "#" data-picker = ".my_page" class = "open-picker">Open the Page</a></p>
                        <p><a href = "#" data-picker = ".my_page" class = "close-picker">Close the Page</a></p>
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
      <div class = "picker-modal my_page">
         <div class = "toolbar">
            <div class = "toolbar-inner">
               <div class = "left"></div>
               <div class = "right"><a href = "#" class = "close-picker">Ok</a></div>
            </div>
         </div>
         <div class = "picker-modal-inner">
            <div class = "content-block">
               <h4>Welcome to Framework7!!!</h4>
               <p>Framework7 - is a free and open source mobile HTML framework to develop hybrid mobile 
                  apps or web apps with iOS & Android native look and feel. It is also an indispensable prototyping 
                  apps tool to show working app prototype as soon as possible in case you need to. </p>
            </div>
         </div>
      </div>
      <script type = "text/javascript" 
         src = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/js/framework7.min.js"></script>
      <script>
         // Here you can initialize the app
         var myApp = new Framework7();
         //If your using custom DOM library, then save it to $$ variable
         var $$ = Dom7;
      </script>
   </body>
</html>

输出 (Output)

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

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

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

  • 点击“打开页面”链接打开选择器模式。 也可以通过单击右上角显示的链接选择器打开该页面。

  • 可以通过单击“关闭页面”选项关闭选择器模式。 选择器模式打开并关闭到任何HTML元素。