index.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. .test-slider-demo{margin: 45px 30px;}
  11. </style>
  12. <div class="layui-fluid">
  13. <div class="layui-row layui-col-space15">
  14. <div class="layui-col-md6">
  15. <div class="layui-card">
  16. <div class="layui-card-header">基础效果</div>
  17. <div class="layui-card-body">
  18. <div id="test-slider-dome1" class="test-slider-demo"></div>
  19. </div>
  20. </div>
  21. <div class="layui-card">
  22. <div class="layui-card-header">定义初始值</div>
  23. <div class="layui-card-body">
  24. <div id="test-slider-dome1" class="test-slider-demo"></div>
  25. </div>
  26. </div>
  27. <div class="layui-card">
  28. <div class="layui-card-header">设置最大最小值</div>
  29. <div class="layui-card-body">
  30. <div id="test-slider-dome3" class="test-slider-demo"></div>
  31. </div>
  32. </div>
  33. <div class="layui-card">
  34. <div class="layui-card-header">设置步长</div>
  35. <div class="layui-card-body">
  36. <div id="test-slider-dome4" class="test-slider-demo"></div>
  37. <div id="test-slider-dome5" class="test-slider-demo"></div>
  38. </div>
  39. </div>
  40. <div class="layui-card">
  41. <div class="layui-card-header">设置提示文本</div>
  42. <div class="layui-card-body">
  43. <div id="test-slider-dome6" class="test-slider-demo"></div>
  44. <div id="test-slider-dome7" class="test-slider-demo"></div>
  45. <div id="test-slider-tips1" style="position:relative; left: 30px; top: -20px;"></div>
  46. </div>
  47. </div>
  48. <div class="layui-card">
  49. <div class="layui-card-header">开启输入框</div>
  50. <div class="layui-card-body">
  51. <div id="test-slider-dome8" class="test-slider-demo"></div>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="layui-col-md6">
  56. <div class="layui-card">
  57. <div class="layui-card-header">开启范围选择</div>
  58. <div class="layui-card-body">
  59. <div id="test-slider-dome9" class="test-slider-demo"></div>
  60. <div id="test-slider-tips2" style="position:relative; left: 30px; margin-top: -10px;"></div>
  61. <div id="test-slider-dome10" class="test-slider-demo"></div>
  62. </div>
  63. </div>
  64. <div class="layui-card">
  65. <div class="layui-card-header">垂直滑块</div>
  66. <div class="layui-card-body">
  67. <div id="test-slider-dome11" style="margin: 45px 30px; display: inline-block;"></div>
  68. <div id="test-slider-dome12" style="margin: 45px 30px; display: inline-block;"></div>
  69. <div id="test-slider-dome13" style="margin: 45px 30px; display: inline-block;"></div>
  70. <div id="test-slider-dome14" style="margin: 45px 30px; display: inline-block;"></div>
  71. </div>
  72. </div>
  73. <div class="layui-card">
  74. <div class="layui-card-header">自定义颜色</div>
  75. <div class="layui-card-body">
  76. <div id="test-slider-dome15" class="test-slider-demo"></div>
  77. <div id="test-slider-dome16" class="test-slider-demo"></div>
  78. <div id="test-slider-dome17" class="test-slider-demo"></div>
  79. </div>
  80. </div>
  81. <div class="layui-card">
  82. <div class="layui-card-header">禁用滑块</div>
  83. <div class="layui-card-body">
  84. <div id="test-slider-dome18" class="test-slider-demo"></div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. <script>
  91. layui.use(['admin', 'slider'], function(){
  92. var $ = layui.$
  93. ,slider = layui.slider;
  94. //默认滑块
  95. slider.render({
  96. elem: '#test-slider-dome1'
  97. });
  98. //定义初始值
  99. slider.render({
  100. elem: '#test-slider-dome2'
  101. ,value: 20 //初始值
  102. });
  103. //设置最大最小值
  104. slider.render({
  105. elem: '#test-slider-dome3'
  106. ,min: 20 //最小值
  107. ,max: 50 //最大值
  108. });
  109. //设置步长
  110. slider.render({
  111. elem: '#test-slider-dome4'
  112. ,step: 10 //步长
  113. });
  114. slider.render({
  115. elem: '#test-slider-dome5'
  116. ,step: 10 //步长
  117. ,showstep: true //开启间隔点
  118. });
  119. //设置提示文本
  120. slider.render({
  121. elem: '#test-slider-dome6'
  122. ,min: 20
  123. ,max: 1000
  124. ,setTips: function(value){ //自定义提示文本
  125. return value + 'GB';
  126. }
  127. });
  128. slider.render({
  129. elem: '#test-slider-dome7'
  130. ,tips: false //关闭默认提示层
  131. ,change: function(value){
  132. $('#test-slider-tips1').html('当前数值:'+ value);
  133. }
  134. });
  135. //开启输入框
  136. slider.render({
  137. elem: '#test-slider-dome8'
  138. ,input: true //输入框
  139. });
  140. //开启范围选择
  141. slider.render({
  142. elem: '#test-slider-dome9'
  143. ,value: 40 //初始值
  144. ,range: true //范围选择
  145. ,change: function(vals){
  146. $('#test-slider-tips2').html('开始值:'+ vals[0] + '、结尾值:'+ vals[1]);
  147. }
  148. });
  149. slider.render({
  150. elem: '#test-slider-dome10'
  151. ,value: [30, 60] //初始值
  152. ,range: true //范围选择
  153. });
  154. //垂直滑块
  155. slider.render({
  156. elem: '#test-slider-dome11'
  157. ,type: 'vertical' //垂直滑块
  158. });
  159. slider.render({
  160. elem: '#test-slider-dome12'
  161. ,value: 30
  162. ,type: 'vertical' //垂直滑块
  163. });
  164. slider.render({
  165. elem: '#test-slider-dome13'
  166. ,value: 50
  167. ,range: true //范围选择
  168. ,type: 'vertical' //垂直滑块
  169. });
  170. slider.render({
  171. elem: '#test-slider-dome14'
  172. ,value: 80
  173. ,input: true //输入框
  174. ,type: 'vertical' //垂直滑块
  175. });
  176. //自定义颜色
  177. slider.render({
  178. elem: '#test-slider-dome15'
  179. ,theme: '#1E9FFF' //主题色
  180. });
  181. slider.render({
  182. elem: '#test-slider-dome16'
  183. ,value: 50
  184. ,theme: '#5FB878' //主题色
  185. });
  186. slider.render({
  187. elem: '#test-slider-dome17'
  188. ,value: [30, 70]
  189. ,range: true
  190. ,theme: '#FF5722' //主题色
  191. });
  192. //禁用滑块
  193. slider.render({
  194. elem: '#test-slider-dome18'
  195. ,value: 35
  196. ,disabled: true //禁用滑块
  197. });
  198. });
  199. </script>