index.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <title>进度条</title>
  2. <div class="layui-card layadmin-header">
  3. <div class="layui-breadcrumb" lay-filter="breadcrumb">
  4. <a lay-href="">主页</a>
  5. <a><cite>组件</cite></a>
  6. <a><cite>进度条</cite></a>
  7. </div>
  8. </div>
  9. <style>
  10. /* 这段样式只是用于演示 */
  11. .layui-progress{margin: 20px 0;}
  12. </style>
  13. <div class="layui-fluid" id="LAY-component-progress">
  14. <div class="layui-row layui-col-space15">
  15. <div class="layui-col-md12">
  16. <div class="layui-card">
  17. <div class="layui-card-header">默认进度条</div>
  18. <div class="layui-card-body">
  19. <div class="layui-progress">
  20. <div class="layui-progress-bar" lay-percent="50%"></div>
  21. </div>
  22. <div class="layui-row layui-col-space15">
  23. <div class="layui-col-xs6">
  24. <div class="layui-progress">
  25. <div class="layui-progress-bar" lay-percent="50%"></div>
  26. </div>
  27. </div>
  28. <div class="layui-col-xs6">
  29. <div class="layui-progress">
  30. <div class="layui-progress-bar" lay-percent="50%"></div>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. <div class="layui-col-md12">
  38. <div class="layui-card">
  39. <div class="layui-card-header">更多颜色进度条</div>
  40. <div class="layui-card-body">
  41. <div class="layui-progress">
  42. <div class="layui-progress-bar layui-bg-red" lay-percent="20%"></div>
  43. </div>
  44. <div class="layui-progress">
  45. <div class="layui-progress-bar layui-bg-orange" lay-percent="30%"></div>
  46. </div>
  47. <div class="layui-progress">
  48. <div class="layui-progress-bar layui-bg-green" lay-percent="40%"></div>
  49. </div>
  50. <div class="layui-progress">
  51. <div class="layui-progress-bar layui-bg-blue" lay-percent="50%"></div>
  52. </div>
  53. <div class="layui-progress">
  54. <div class="layui-progress-bar layui-bg-cyan" lay-percent="60%"></div>
  55. </div>
  56. <div class="layui-progress layui-progress-big">
  57. <div class="layui-progress-bar" lay-percent="20%"></div>
  58. </div>
  59. <div class="layui-progress layui-progress-big">
  60. <div class="layui-progress-bar layui-bg-green" lay-percent="35%"></div>
  61. </div>
  62. <div class="layui-progress layui-progress-big">
  63. <div class="layui-progress-bar layui-bg-cyan" lay-percent="75%"></div>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. <div class="layui-col-md12">
  69. <div class="layui-card">
  70. <div class="layui-card-header">动态改变进度</div>
  71. <div class="layui-card-body">
  72. <div class="layui-progress layui-progress-big" lay-showpercent="true" lay-filter="component-progress-demo">
  73. <div class="layui-progress-bar layui-bg-red" lay-percent="0%"></div>
  74. </div>
  75. <div class="layui-btn-container" style="margin-top: 20px; margin-bottom: 0;">
  76. <button class="layui-btn site-demo-active" data-type="setPercent">设置50%</button>
  77. <button class="layui-btn site-demo-active" data-type="loading">模拟loading</button>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="layui-col-md12">
  83. <div class="layui-card">
  84. <div class="layui-card-header">显示进度比文本</div>
  85. <div class="layui-card-body">
  86. <div class="layui-progress" lay-showpercent="true">
  87. <div class="layui-progress-bar" lay-percent="20%"></div>
  88. </div>
  89. <div class="layui-progress" lay-showpercent="true">
  90. <div class="layui-progress-bar" lay-percent="5 / 10"></div>
  91. </div>
  92. <div class="layui-progress layui-progress-big" lay-showpercent="true">
  93. <div class="layui-progress-bar" lay-percent="70%"></div>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. <script>
  101. layui.use(['admin'], function(){
  102. var $ = layui.$
  103. ,admin = layui.admin
  104. ,element = layui.element
  105. ,router = layui.router();
  106. element.render('progress');
  107. //触发事件
  108. var active = {
  109. setPercent: function(){
  110. //设置50%进度
  111. element.progress('component-progress-demo', '50%')
  112. }
  113. ,loading: function(othis){
  114. var DISABLED = 'layui-btn-disabled';
  115. if(othis.hasClass(DISABLED)) return;
  116. //模拟loading
  117. var n = 0, timer = setInterval(function(){
  118. n = n + Math.random()*10|0;
  119. if(n>100){
  120. n = 100;
  121. clearInterval(timer);
  122. othis.removeClass(DISABLED);
  123. }
  124. element.progress('component-progress-demo', n+'%');
  125. }, 300+Math.random()*1000);
  126. othis.addClass(DISABLED);
  127. }
  128. };
  129. $('#LAY-component-progress .site-demo-active').on('click', function(){
  130. var othis = $(this), type = $(this).data('type');
  131. active[type] ? active[type].call(this, othis) : '';
  132. });
  133. });
  134. </script>