更新记录
1.0.0(2023-05-15) 下载此版本
score 评分组件
平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | √ | √ | - | - | - | - | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
√ | √ | √ | √ | - | - | - | √ | - | - | - |
其他
多语言 | 暗黑模式 | 宽屏模式 |
---|---|---|
× | × | √ |
属性说明
属性名 | 类型 | 默认 | 说明 |
---|---|---|---|
disabled | Boolean | false | 是否为禁用状态,默认为 false |
margin | Number | 5(px) | 星星的间距,单位 px |
value | Number | 0 | value/v-model 当前评分 |
max | Number | 5 | 最大评分评分数量,目前一分一颗星 |
isFill | Boolean | false | 星星的类型,是否为实心类型, 默认为实心 |
size | Number | 24 | size 星星的大小 |
isImg | Boolean | false | 是否图片,默认为false(如果为true则字体图片相关配置无效) |
starDefault | String | icon-shoucangxiao1 | 字体图标默认 |
starFilled | String | icon-shoucangxiao | 字体图标高亮 |
starDefault | String | -- | 图片图标默认 |
starImgFilled | String | -- | 图片图标高亮 |
color | String | #ececec | 字体图标未选中的颜色,默认为#ececec |
activeColor | String | #FA7819 | 字体图标选中的颜色,默认为#ffca3e |
disabledColor | String | #c0c0c0 | 禁用状态的星星颜色,默认为 "#c0c0c0" |
readonly | Boolean | false | 是否为只读状态,默认为 false |
touchable | Boolean | true | 是否支持滑动手势,默认为 true |
change | Function | -- | uniScore 的 value 改变时触发事件,e={value:Number} |
Tips
使用的是阿里的iconfont,不是uni-icon
平台差异
测试支持H5,微信小程序,APP;
理论支持其他平台,未测试nvue,
调用示例
<template>
<view class="page-body">
<view class="span-box">
<view class="iden"></view>
基础用法
</view>
<score-box v-model="value"></score-box>
<view class="span-box">
<view class="iden"></view>
设置尺寸大小
</view>
<score-box :size="15" v-model="value"></score-box>
<view class="span-box">
<view class="iden"></view>
设置评分数
</view>
<score-box v-model="value" :max="10"></score-box>
<view class="span-box">
<view class="iden"></view>
设置星星间隔
</view>
<score-box v-model="value" :margin="20"></score-box>
<view class="span-box">
<view class="iden"></view>
设置颜色(如果isImg为true则无效)
</view>
<score-box v-model="value" activeColor="red" color="#999999"></score-box>
<view class="span-box">
<view class="iden"></view>
星星镂空状态
</view>
<score-box v-model="value" :isFill="true"></score-box>
</view>
</template>
<script>
export default {
data() {
return {
value: 3
}
}
}
</script>
<style lang="scss" scoped>
.page-body {
margin: 0 20px;
}
.span-box {
display: flex;
align-items: center;
margin-bottom: 10px;
margin-top: 20px;
}
.iden {
width: 2px;
height: 15px;
background: #FA7819;
margin-right: 10px;
}
</style>