You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
layui/examples/rate.html

119 lines
2.1 KiB

7 years ago
<!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>
7 years ago
<div class="layui-container">
<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>
7 years ago
</div>
7 years ago
<script src="../src/layui.js"></script>
<script>
7 years ago
layui.use(['rate'], function(){
var rate = layui.rate;
7 years ago
7 years ago
//渲染
// rate.set({
// elem: '#test1'
// ,length: 7
// ,value: 4.7
// ,theme: '#c00'
// ,half: true
// ,text: true
// ,reader: true
// })
7 years ago
rate.render({
7 years ago
elem: '#test1'
,length: 3
4 years ago
,value: 3.2
,text: true
,half: true
,setText: function(value){
var arrs = {
'0.5': '极差'
, '1' : '一般'
,'1.5': '满意'
,'2': '极满意'
};
this.span.text(arrs[value] || ( value + "星"));
}
7 years ago
})
7 years ago
7 years ago
rate.render({
7 years ago
elem: '#test2'
,length: 6
,value: 2
,half: true
7 years ago
,theme: '#5FB878'
,choose: function(value){
if( value > 3) alert("111")
}
7 years ago
})
7 years ago
rate.render({
7 years ago
elem: '#test3'
,length: 3
7 years ago
,value: 2.8
7 years ago
,text: true
,half: true
7 years ago
,theme: '#FF5722'
7 years ago
})
7 years ago
//只读
7 years ago
rate.render({
7 years ago
elem: '#test4'
7 years ago
,value: 3.5
,half: true
,readonly: true
7 years ago
})
7 years ago
});
</script>
</body>
</html>