123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <title>评分组件</title>
- <div class="layui-card layadmin-header">
- <div class="layui-breadcrumb" lay-filter="breadcrumb">
- <a lay-href="">主页</a>
- <a><cite>组件</cite></a>
- <a><cite>评分组件</cite></a>
- </div>
- </div>
- <div class="layui-fluid">
- <div class="layui-row layui-col-space15">
- <div class="layui-col-md6">
- <div class="layui-card">
- <div class="layui-card-header">基础效果</div>
- <div class="layui-card-body">
- <div id="test-rate-dome1"></div>
- </div>
- </div>
- <div class="layui-card">
- <div class="layui-card-header">显示文字</div>
- <div class="layui-card-body">
- <div id="test-rate-dome2"></div>
- </div>
- </div>
- <div class="layui-card">
- <div class="layui-card-header">半星效果</div>
- <div class="layui-card-body">
- <div id="test-rate-dome3"></div>
- <div><div id="test-rate-dome4"></div></div>
- </div>
- </div>
- <div class="layui-card">
- <div class="layui-card-header">自定义主题色</div>
- <div class="layui-card-body">
- <ul>
- <li><div id="test-rate-dome10"></div></li>
- <li><div id="test-rate-dome11"></div></li>
- <li><div id="test-rate-dome12"></div></li>
- <li><div id="test-rate-dome13"></div></li>
- <li><div id="test-rate-dome14"></div></li>
- </ul>
- </div>
- </div>
- </div>
- <div class="layui-col-md6">
- <div class="layui-card">
- <div class="layui-card-header">只读</div>
- <div class="layui-card-body">
- <div id="test-rate-dome9"></div>
- </div>
- </div>
- <div class="layui-card">
- <div class="layui-card-header">自定义内容</div>
- <div class="layui-card-body">
- <div id="test-rate-dome5"></div>
- <div><div id="test-rate-dome6"></div></div>
- </div>
- </div>
- <div class="layui-card">
- <div class="layui-card-header">自定义长度</div>
- <div class="layui-card-body">
- <div id="test-rate-dome7"></div>
- <div><div id="test-rate-dome8"></div></div>
- </div>
- </div>
- </div>
-
- </div>
- </div>
- <script>
- layui.use(['admin', 'rate'], function(){
- var rate = layui.rate;
- //基础效果
- rate.render({
- elem: '#test-rate-dome1'
- })
-
- //显示文字
- rate.render({
- elem: '#test-rate-dome2'
- ,value: 2 //初始值
- ,text: true //开启文本
- });
-
- //半星效果
- rate.render({
- elem: '#test-rate-dome3'
- ,value: 2.5 //初始值
- ,half: true //开启半星
- })
- rate.render({
- elem: '#test-rate-dome4'
- ,value: 3.5
- ,half: true
- ,text: true
- })
-
- //自定义文本
- rate.render({
- elem: '#test-rate-dome5'
- ,value: 3
- ,text: true
- ,setText: function(value){ //自定义文本的回调
- var arrs = {
- '1': '极差'
- ,'2': '差'
- ,'3': '中等'
- ,'4': '好'
- ,'5': '极好'
- };
- this.span.text(arrs[value] || ( value + "星"));
- }
- })
- rate.render({
- elem: '#test-rate-dome6'
- ,value: 1.5
- ,half: true
- ,text: true
- ,setText: function(value){
- this.span.text(value);
- }
- })
-
- //自定义长度
- rate.render({
- elem: '#test-rate-dome7'
- ,length: 3
- });
- rate.render({
- elem: '#test-rate-dome8'
- ,length: 10
- ,value: 8 //初始值
- });
-
- //只读
- rate.render({
- elem: '#test-rate-dome9'
- ,value: 4
- ,readonly: true
- });
-
- //主题色
- rate.render({
- elem: '#test-rate-dome10'
- ,value: 3
- ,theme: '#FF8000' //自定义主题色
- });
- rate.render({
- elem: '#test-rate-dome11'
- ,value: 3
- ,theme: '#009688'
- });
-
- rate.render({
- elem: '#test-rate-dome12'
- ,value: 2.5
- ,half: true
- ,theme: '#1E9FFF'
- })
- rate.render({
- elem: '#test-rate-dome13'
- ,value: 2.5
- ,half: true
- ,theme: '#2F4056'
- });
- rate.render({
- elem: '#test-rate-dome14'
- ,value: 2.5
- ,half: true
- ,theme: '#FE0000'
- })
- });
- </script>
|