一套开源的 Web UI 组件库。采用自身极简的模块化规范,并遵循原生 HTML/CSS/JS 的开发模式,极易上手,开箱即用。非常适合网页界面的快速构建。
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.

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'
4 years ago
,length: 5
,value: 5
,text: true
,half: true
4 years ago
,setText1: 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>