目录

用于弹出转换的操作表(Action sheet to popover coversion)

描述 (Description)

Popover无法用于平板电脑上的手机(iPhone)和动作表,因此您可以使用扩展的ActionSheet语法,它将动作表转换为平板电脑上的自动弹出窗口。 您可以使用如下所示的方法 -

  • myApp.actions(target, groups) - 用于创建和打开具有已定义数量的按钮组的Action Sheet(或平板电脑上的popover)。

  • OR

  • myApp.actions(target, buttons) - 用于使用组和按钮创建和打开操作表(或平板电脑上的弹出窗口)。

    • target - 它是目标元素的HTMLElementstring (with CSS Selector) 。 这是必需的参数。

    • groups - 这是一个array of groups其中每个组都有一个按钮数组。

    • buttons - 这是一个array of buttons其中将有one group

例子 (Example)

下面的示例演示如何在Framework7中将Action Sheet转换为Popover,当您单击链接时将其转换为popover -

<!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>Convert Action Sheet to Popover</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">Action Sheet</div>
                        <div class = "right"> </div>
                     </div>
                  </div>
                  <div class = "page-content">
                     <div class = "content-block">
                        <p><a href = "#" class = "ac-1">Convert Action Sheet to Popover</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();
         var $$ = Dom7;
         $$('.ac-1').on('click', function (e) {
            var target = this;
            var buttons = [
               {
                  text: 'Button 1'
               },
               {
                  text: 'Button 2'
               }
            ];
            myApp.actions(target, buttons);
         });
      </script>
   </body>
</html>

输出 (Output)

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

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

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

  • 单击选项可将操作表转换为在平板电脑上自动弹出。 单击时,将打开一个窗口,其中包含两个选项,如下所示。

新页面打开
↑回到顶部↑
WIKI教程 @2018