Framework7 - 预加载模态框



描述

预加载模态框定义了背景操作,并在该操作期间阻止用户操作。它使用以下方法打开预加载模态框:

  • myApp.showPreloader([title])

    • title - 这是一个可选方法,用于显示带有标题的预加载模态框。

示例

以下示例演示了在 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>Preloader Modal</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 = "navbar">
               <div class = "navbar-inner">
                  <div class = "center sliding">Preloader Modal</div>
               </div>
            </div>
            
            <div class = "pages">
               <div data-page = "index" class = "page navbar-fixed">
                  <div class = "page-content">
                     <div class = "content-block">
                        <p><a href = "#" class = "preloader_open">Display the Preloader</a></p>
                        <p><a href = "#" class = "preloader_title">Display the Preloader with title</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>
         // Here you can initialize the app
         var myApp = new Framework7();

         // If your using custom DOM library, then save it to $$ variable
         var $$ = Dom7;

         // Add the view
         var mainView = myApp.addView('.view-main', {
            // enable the dynamic navbar for this view:
            dynamicNavbar: true
         });

         $$('.preloader_open').on('click', function () {
            myApp.showPreloader();
            setTimeout(function () {
               myApp.hidePreloader();
            }, 1500);
         });
         
         $$('.preloader_title').on('click', function () {
            myApp.showPreloader('My Title')
            setTimeout(function () {
               myApp.hidePreloader();
            }, 1500);
         });
      </script>
   </body>

</html>

输出

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

  • 将上面给出的 HTML 代码保存为modal_preloader.html文件,并将其放置在服务器根文件夹中。

  • 以 https:///modal_preloader.html 的方式打开此 HTML 文件,输出将如下所示。

  • 当点击第一个选项时,它会显示预加载模态框。

  • 当点击第二个选项时,它会显示带有标题的预加载模态框。

framework7_overlays.htm
广告

© . All rights reserved.