2018-04-24 10:21:01 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
|
|
<title>评分 - layui</title>
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../src/css/layui.css">
|
|
|
|
|
|
|
|
<style>
|
|
|
|
body{padding:20px;}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
2018-04-24 14:56:49 +08:00
|
|
|
<div class="layui-container">
|
2018-04-28 10:59:55 +08:00
|
|
|
<div class="layui-row">
|
|
|
|
<!-- 基础评分用法 -->
|
|
|
|
<div class="layui-rate-div layui-col-xm4 layui-col-xm-offset4 ">
|
|
|
|
<h3>基础用法</h3>
|
|
|
|
<hr>
|
|
|
|
<div id="test1"></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- 半星评分用法 -->
|
|
|
|
<div class="layui-rate-div layui-col-xm4 layui-col-xm-offset4 ">
|
|
|
|
<h3>选中半星</h3>
|
|
|
|
<hr>
|
|
|
|
<div id="test2"></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- 显示提示文字 -->
|
|
|
|
<div class="layui-rate-div layui-col-xm4 layui-col-xm-offset4 ">
|
|
|
|
<h3>显示提示文字</h3>
|
|
|
|
<hr>
|
|
|
|
<div id="test3"></div>
|
|
|
|
<span></span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- 只读 -->
|
|
|
|
<div class="layui-rate-div layui-col-xm4 layui-col-xm-offset4 ">
|
|
|
|
<h3>只读</h3>
|
|
|
|
<hr>
|
|
|
|
<div id="test4"></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
2018-04-24 14:56:49 +08:00
|
|
|
</div>
|
2018-04-24 10:21:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
<script src="../src/layui.js"></script>
|
|
|
|
<script>
|
|
|
|
|
2018-04-24 14:56:49 +08:00
|
|
|
layui.use(['rate'], function(){
|
|
|
|
var rate = layui.rate;
|
2018-04-24 17:57:31 +08:00
|
|
|
|
2018-04-25 16:11:15 +08:00
|
|
|
//渲染
|
2018-04-28 10:54:27 +08:00
|
|
|
|
|
|
|
// rate.set({
|
|
|
|
// elem: '#test1'
|
|
|
|
// ,length: 7
|
|
|
|
// ,value: 4.7
|
|
|
|
// ,theme: '#c00'
|
|
|
|
// ,half: true
|
|
|
|
// ,text: true
|
|
|
|
// ,reader: true
|
|
|
|
// })
|
|
|
|
|
2018-04-25 16:11:15 +08:00
|
|
|
rate.render({
|
2018-04-25 19:21:27 +08:00
|
|
|
elem: '#test1'
|
2021-04-22 10:22:45 +08:00
|
|
|
,length: 5
|
|
|
|
,value: 5
|
2018-04-28 10:54:27 +08:00
|
|
|
,text: true
|
|
|
|
,half: true
|
2021-04-22 10:22:45 +08:00
|
|
|
,setText1: function(value){
|
2018-04-28 10:54:27 +08:00
|
|
|
|
|
|
|
var arrs = {
|
|
|
|
'0.5': '极差'
|
|
|
|
, '1' : '一般'
|
|
|
|
,'1.5': '满意'
|
|
|
|
,'2': '极满意'
|
|
|
|
};
|
|
|
|
|
|
|
|
this.span.text(arrs[value] || ( value + "星"));
|
|
|
|
}
|
2018-04-25 16:11:15 +08:00
|
|
|
})
|
2018-04-25 19:21:27 +08:00
|
|
|
|
2018-04-25 16:11:15 +08:00
|
|
|
rate.render({
|
2018-04-25 19:21:27 +08:00
|
|
|
elem: '#test2'
|
|
|
|
,length: 6
|
|
|
|
,value: 2
|
|
|
|
,half: true
|
2018-04-26 14:00:57 +08:00
|
|
|
,theme: '#5FB878'
|
2018-04-28 10:54:27 +08:00
|
|
|
,choose: function(value){
|
|
|
|
if( value > 3) alert("111")
|
|
|
|
}
|
2018-04-25 16:11:15 +08:00
|
|
|
})
|
2018-04-28 10:54:27 +08:00
|
|
|
|
2018-04-25 16:11:15 +08:00
|
|
|
rate.render({
|
2018-04-25 19:21:27 +08:00
|
|
|
elem: '#test3'
|
2018-04-28 10:54:27 +08:00
|
|
|
,length: 3
|
2018-04-26 14:00:57 +08:00
|
|
|
,value: 2.8
|
2018-04-25 19:21:27 +08:00
|
|
|
,text: true
|
|
|
|
,half: true
|
2018-04-26 14:00:57 +08:00
|
|
|
,theme: '#FF5722'
|
2018-04-25 16:11:15 +08:00
|
|
|
})
|
2018-05-08 15:51:37 +08:00
|
|
|
|
|
|
|
//只读
|
2018-04-25 16:11:15 +08:00
|
|
|
rate.render({
|
2018-04-25 19:21:27 +08:00
|
|
|
elem: '#test4'
|
2018-05-08 15:51:37 +08:00
|
|
|
,value: 3.5
|
|
|
|
,half: true
|
|
|
|
,readonly: true
|
2018-04-24 17:57:31 +08:00
|
|
|
})
|
2018-04-24 10:21:01 +08:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|