2018-08-18 20:46:14 +08:00
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html>
|
|
|
|
|
<head>
|
2022-08-29 23:53:12 +08:00
|
|
|
|
<meta charset="utf-8">
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
|
|
|
<title>滑块 - layui</title>
|
2018-08-18 20:46:14 +08:00
|
|
|
|
|
2022-08-29 23:53:12 +08:00
|
|
|
|
<link rel="stylesheet" href="../src/css/layui.css">
|
|
|
|
|
<style>
|
|
|
|
|
body{padding:100px 0;}
|
|
|
|
|
</style>
|
2018-08-18 20:46:14 +08:00
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
|
2023-03-19 23:24:18 +08:00
|
|
|
|
<div class="layui-container">
|
|
|
|
|
<div id="slideTest1"></div>
|
|
|
|
|
<br>
|
|
|
|
|
<div id="slideTest2" style="margin: 45px 30px; display: inline-block;"></div>
|
|
|
|
|
</div>
|
2018-08-18 20:46:14 +08:00
|
|
|
|
|
|
|
|
|
<script src="../src/layui.js"></script>
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
|
|
layui.use('slider', function(){
|
|
|
|
|
var slider = layui.slider;
|
2018-08-28 15:43:16 +08:00
|
|
|
|
|
2019-09-10 08:37:47 +08:00
|
|
|
|
var sliderInst = slider.render({
|
2018-08-18 20:46:14 +08:00
|
|
|
|
elem: '#slideTest1'
|
2018-08-28 15:43:16 +08:00
|
|
|
|
//,type: 'vertical'
|
2018-11-01 02:50:21 +08:00
|
|
|
|
//,min: -20 //最小值
|
|
|
|
|
//,max: 20 //最大值
|
2022-08-29 23:53:12 +08:00
|
|
|
|
//,value: 11 //[40, 60] //初始值
|
|
|
|
|
//,step: 1 //间隔值
|
2018-08-28 15:43:16 +08:00
|
|
|
|
//,showstep: true //间隔点
|
|
|
|
|
//,tips: false //关闭提示文本
|
|
|
|
|
,input: true //输入框
|
|
|
|
|
//,range: true //范围选择
|
2022-08-29 23:53:12 +08:00
|
|
|
|
//,theme: '#FF5722'
|
|
|
|
|
,change: function(value){ // 选中值发生改变的回调
|
|
|
|
|
console.log('change', value)
|
|
|
|
|
}
|
|
|
|
|
,done: function(value){ // 值完成选中的回调 -- v2.8.0 新增
|
|
|
|
|
console.log('done', value);
|
2018-08-28 15:43:16 +08:00
|
|
|
|
}
|
2020-11-26 22:12:46 +08:00
|
|
|
|
,setTips: function(value){ //自定义提示文本
|
|
|
|
|
return value + '%';
|
|
|
|
|
}
|
2018-08-28 15:43:16 +08:00
|
|
|
|
//,setTips: function(value){ //自定义提示文本
|
|
|
|
|
//return '离世界末日还有 ' + value + ' 天';
|
|
|
|
|
//}
|
|
|
|
|
//,height: '300' //配合 type:'vertical' 参数使用,默认200px
|
|
|
|
|
//,disabled: true //禁用滑块
|
|
|
|
|
//,theme: '#c00' //主题色
|
2018-08-18 20:46:14 +08:00
|
|
|
|
});
|
2019-09-10 08:37:47 +08:00
|
|
|
|
|
2022-08-29 23:53:12 +08:00
|
|
|
|
//sliderInst.setValue(30);
|
2022-07-17 12:31:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
slider.render({
|
|
|
|
|
elem: '#slideTest2',
|
|
|
|
|
type: 'vertical'
|
|
|
|
|
});
|
2018-08-18 20:46:14 +08:00
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|