FineUI 官方论坛
标题:
FineUI 评分控件
[打印本页]
作者:
棕榈
时间:
2020-2-10 11:56
标题:
FineUI 评分控件
本帖最后由 棕榈 于 2020-2-10 11:54 编辑
FineUI 评分控件
[attach]12215[/attach]
评分控件是在FineUI的NumberBox基础上构建的,与之前创建FineUI进度条方法是一样的,具体的实现原理请查看FineUI 进度条
https://fineui.com/bbs/forum.php?mod=viewthread&tid=22352&fromuid=5871
,下面讲一下控件的使用
使用原理与进度条是一样的,也是添加Attribute,由于评分控件的参数要多一些,所以可添加的属性也多一些
最简单的使用,默认为五角星,个数为5个,大小为20
<f:NumberBox Text="2">
<Attributes>
<f:Attribute Key="role" Value="rating"></f:Attribute>
</Attributes>
</f:NumberBox>
复制代码
最全的参数:
<f:NumberBox Text="8">
<Attributes>
<f:Attribute Key="role" Value="rating"></f:Attribute>
<f:Attribute Key="data-icon" Value="diamond"></f:Attribute>
<f:Attribute Key="data-count" Value="11"></f:Attribute>
<f:Attribute Key="data-size" Value="20"></f:Attribute>
<f:Attribute Key="data-color" Value="#16a085"></f:Attribute>
<f:Attribute Key="data-allow-half" Value="true"></f:Attribute>
<f:Attribute Key="data-readonly" Value="false"></f:Attribute>
</Attributes>
</f:NumberBox>
复制代码
使用之前需要引入JS文件及调用初始化方法
<script src="~/res/js/fineui-rating.js"></script>
<script>
F.ready(function () {
F.ext.rating();
});
</script>
复制代码
下面为示例代码:
@page
@model FineUICore.EmptyProject.RazorPages.Pages.RatingModel
@{
ViewBag.Title = "评分控件";
var F = @Html.F();
}
@section body {
<h2>评分控件</h2>
<f:NumberBox Text="2">
<Attributes>
<f:Attribute Key="role" Value="rating"></f:Attribute>
</Attributes>
</f:NumberBox>
<br />
<h3>不同的图标(使用FineUI内置的字体图标)、个数、大小、颜色</h3>
<f:NumberBox Text="3">
<Attributes>
<f:Attribute Key="role" Value="rating"></f:Attribute>
<f:Attribute Key="data-icon" Value="heart"></f:Attribute>
<f:Attribute Key="data-count" Value="6"></f:Attribute>
<f:Attribute Key="data-size" Value="30"></f:Attribute>
<f:Attribute Key="data-color" Value="#c0392b"></f:Attribute>
</Attributes>
</f:NumberBox>
<br />
<f:NumberBox Text="4">
<Attributes>
<f:Attribute Key="role" Value="rating"></f:Attribute>
<f:Attribute Key="data-icon" Value="thumbs-up"></f:Attribute>
<f:Attribute Key="data-count" Value="7"></f:Attribute>
<f:Attribute Key="data-size" Value="28"></f:Attribute>
<f:Attribute Key="data-color" Value="#2980b9"></f:Attribute>
</Attributes>
</f:NumberBox>
<br />
<f:NumberBox Text="5">
<Attributes>
<f:Attribute Key="role" Value="rating"></f:Attribute>
<f:Attribute Key="data-icon" Value="trophy"></f:Attribute>
<f:Attribute Key="data-count" Value="8"></f:Attribute>
<f:Attribute Key="data-size" Value="26"></f:Attribute>
<f:Attribute Key="data-color" Value="#e67e22"></f:Attribute>
</Attributes>
</f:NumberBox>
<br />
<f:NumberBox Text="6">
<Attributes>
<f:Attribute Key="role" Value="rating"></f:Attribute>
<f:Attribute Key="data-icon" Value="smile-o"></f:Attribute>
<f:Attribute Key="data-count" Value="9"></f:Attribute>
<f:Attribute Key="data-size" Value="24"></f:Attribute>
<f:Attribute Key="data-color" Value="#27ae60"></f:Attribute>
</Attributes>
</f:NumberBox>
<br />
<f:NumberBox Text="7">
<Attributes>
<f:Attribute Key="role" Value="rating"></f:Attribute>
<f:Attribute Key="data-icon" Value="snowflake-o"></f:Attribute>
<f:Attribute Key="data-count" Value="10"></f:Attribute>
<f:Attribute Key="data-size" Value="22"></f:Attribute>
<f:Attribute Key="data-color" Value="#f1c40f"></f:Attribute>
</Attributes>
</f:NumberBox>
<br />
<f:NumberBox Text="8">
<Attributes>
<f:Attribute Key="role" Value="rating"></f:Attribute>
<f:Attribute Key="data-icon" Value="diamond"></f:Attribute>
<f:Attribute Key="data-count" Value="11"></f:Attribute>
<f:Attribute Key="data-size" Value="20"></f:Attribute>
<f:Attribute Key="data-color" Value="#16a085"></f:Attribute>
</Attributes>
</f:NumberBox>
<br />
<h3>允许半选</h3>
<f:NumberBox Text="1.5">
<Attributes>
<f:Attribute Key="role" Value="rating"></f:Attribute>
<f:Attribute Key="data-allow-half" Value="true"></f:Attribute>
</Attributes>
</f:NumberBox>
<br />
<h3>设为只读</h3>
<f:NumberBox Text="3">
<Attributes>
<f:Attribute Key="role" Value="rating"></f:Attribute>
<f:Attribute Key="data-readonly" Value="true"></f:Attribute>
</Attributes>
</f:NumberBox>
<br />
<h3>change事件</h3>
<f:NumberBox ID="rating2" Text="3">
<Listeners>
<f:Listener Event="change" Handler="onRatingChange"></f:Listener>
</Listeners>
<Attributes>
<f:Attribute Key="role" Value="rating"></f:Attribute>
<f:Attribute Key="data-allow-half" Value="true"></f:Attribute>
</Attributes>
</f:NumberBox>
<br />
<f:NumberBox ID="numberbox" Text="3">
<Listeners>
<f:Listener Event="change" Handler="onNumberBoxChange"></f:Listener>
</Listeners>
</f:NumberBox>
<br />
<h3>通过后台程序设置</h3>
<f:NumberBox ID="rating" Text="0">
<Attributes>
<f:Attribute Key="role" Value="rating"></f:Attribute>
</Attributes>
</f:NumberBox>
<br />
<f:Button Text="0" ID="btnSetRatingValue_0" OnClick="@Url.Handler("btnSetRatingValue_Click")" OnClickParameter1="@(new Parameter("value", "0"))"></f:Button>
<f:Button Text="3" ID="btnSetRatingValue_3" OnClick="@Url.Handler("btnSetRatingValue_Click")" OnClickParameter1="@(new Parameter("value", "3"))"></f:Button>
<f:Button Text="4.3" ID="btnSetRatingValue_4_3" OnClick="@Url.Handler("btnSetRatingValue_Click")" OnClickParameter1="@(new Parameter("value", "4.3"))"></f:Button>
<f:Button Text="5" ID="btnSetRatingValue_5" OnClick="@Url.Handler("btnSetRatingValue_Click")" OnClickParameter1="@(new Parameter("value", "5"))"></f:Button>
}
@section script {
<script src="~/res/js/fineui-rating.js"></script>
<script>
function onRatingChange() {
F.ui.numberbox.setValue(F.ui.rating2.getValue());
};
function onNumberBoxChange() {
F.ui.rating2.setValue(F.ui.numberbox.getValue());
}
F.ready(function () {
F.ext.rating();
});
</script>
}
复制代码
fineui-rating.js 文件请到知识星球下载
作者:
sanshi
时间:
2020-2-10 12:10
厉害厉害
作者:
在路上。。。
时间:
2020-2-11 09:18
厉害厉害
作者:
hroger
时间:
2020-11-23 23:05
如何在FinePro里面使用呢?
作者:
hroger
时间:
2020-11-23 23:19
目前是直接报错
欢迎光临 FineUI 官方论坛 (https://fineui.com/BBS/)
Powered by Discuz! X3.4