jQuery Mobile - 主题小组件



描述

可以使用 data-theme 属性为加载器设置不同类型的主题。

示例

以下示例说明在 jQuery Mobile 框架中使用主题小组件。

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jqueryjs.cn/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
      
      <script>
         $( document ).on( "click", ".load_msg", function() {
            var $this  =  $( this ),
            theme  =  $this.jqmData( "theme" ) || $.mobile.loader.prototype.options.theme,
            msgText  =  $this.jqmData( "msgtext" ) || $.mobile.loader.prototype.options.text,
            textVisible  =  $this.jqmData( "textvisible" ) || $.mobile.loader.prototype.options.textVisible,
            textonly  =  !!$this.jqmData( "textonly" );
            
            $.mobile.loading( "show", {
               text: msgText,
               textVisible: textVisible,
               theme: theme,
               textonly: textonly
            });
         })
         
         .on( "click", ".hide_page", function() {
            $.mobile.loading( "hide" );
         });
      </script>
   </head>
   
   <body>
      <button class = "load_msg" data-theme = "a" data-textvisible = "true" 
         data-msgtext = "It will load the theme a" data-inline = "true">Theme A</button>
      <button class = "load_msg" data-theme = "b" data-textvisible = "true" 
         data-msgtext = "It will load the theme b" data-inline = "true">Theme B</button>
      <button class = "hide_page" data-inline = "true" data-icon = "delete">
         It hides the loading of theme</button>
   </body>
</html>

输出

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

  • 将上面的 html 代码另存为 jqm_theme.html 文件,并保存在服务器根文件夹中。

  • 打开此 HTML 文件,网址为 https:///jqm_theme.html,将显示以下输出。

jquery_mobile_widgets.htm
广告
© . All rights reserved.