lc-rater

星级评分组件

注意事项

  • 支持单显示模式
  • 提供两种大小
  • 提供三种不同的主题模式,来适应不同的应用场景

效果

使用方法

<template>
<div class="lc-demo">

<scroller class="scroller">
<title title="lc-rater"></title>
<category title="不同大小"></category>
<div class="container">
<lc-rater :score="score1" @lcRaterScoreChanged="scoreChanged"></lc-rater>
<text class="sc"> {{score}} 分</text>
</div>
<div class="container">
<lc-rater size="small"></lc-rater>
</div>
<category title="不同主题颜色"></category>
<div class="container">
<lc-rater theme="normal"></lc-rater>
</div>
<div class="container">
<lc-rater theme="normal" size='small'></lc-rater>
</div>
<div class="container">
<lc-rater theme="special"></lc-rater>
</div>
<div class="container">
<lc-rater theme="special" size='small'></lc-rater>
</div>
<div class="container dark">
<lc-rater theme="dark"></lc-rater>
</div>
<div class="container dark">
<lc-rater theme="dark" size='small'></lc-rater>
</div>
<div class="container">
<lc-rater size='small'></lc-rater>
</div>
<category title="不同的初始化分数"></category>
<div class="container">
<lc-rater :score="2" :canChange="false"></lc-rater>
</div>
<div class="container">
<lc-rater :score="4" :canChange="false"></lc-rater>
</div>
<div class="container">
<lc-rater :score="6" :canChange="false"></lc-rater>
</div>
<category title="分数更改后回调"></category>
<div class="container">
<lc-rater @lcRaterScoreChanged="scoreChanged"></lc-rater>
</div>
</scroller>

</div>
</template>

<script>
import Light from 'light';
import Title from 'lighting-ui/packages/_mods/title.vue';
import Category from 'lighting-ui/packages/_mods/category.vue';
import LcRater from 'lighting-ui/packages/lc-rater';
const modal = Light.requireModule('modal');

export default {
components: { Title, Category, LcRater },
data(){
return {
score1:2,
score:null
}
},
methods: {
scoreChanged (e) {
this.score = e.score
modal.toast({ message: e.score });
}
},
mounted() {
this.score = this.score1
},
};
</script>
<style scoped>
.container {
flex-direction: row;
align-items: center;
justify-content: center;
margin-top: 50px;
}
.dark {
background-color: rgb(74, 74, 74);
}
.sc{ font-size: 40px; color: orange; font-weight: bold;}
</style>

可配置参数

Prop Type Required Default Description
score Number N 0 当前分数
fullScore Object N 10 最大分数
size String N big 大小,有 small 和 big 两种
theme String N normal 主题,有 normal、special、dark 三种
can-change Boolean N true 是否允许更改分数,当为 true 时,用户可以通过点击或者滑动以 0.5 格步进更改分数值
can-slide Boolean N true 是否允许滑动更改分数,当为 false 时,用户只能通过点击更改分数值
star-img Array/String N - 自定义星星图片,应传入长度为 5 的数组或字符串
bg-img Array/String N - 自定义星星背景图片

事件回调

lcRaterScoreChanged: 分数更改时触发, score: 当前分数