Skip to content
On this page

Rate 评分

注:

  • 支持表单,具体可参考 Form
vue
<template>
  <ta-group title="基础用法">
    <ta-cell label="默认"><ta-rate /></ta-cell>
    <ta-cell label="modelValue=3"><ta-rate modelValue="3" /></ta-cell>
  </ta-group>
  <ta-group title="风格">
    <ta-cell label="爱心 icon='HeartOutlined' activeIcon='HeartFilled'"
      ><ta-rate icon="HeartOutlined" activeIcon="HeartFilled" modelValue="3"
    /></ta-cell>
    <ta-cell label="换色 activeColor='#F5A511'"
      ><ta-rate modelValue="3" activeColor="#F5A511"
    /></ta-cell>
    <ta-cell label="变小 size='16px'"><ta-rate modelValue="3" size="16" /></ta-cell>
  </ta-group>
  <ta-group title="自定义数量">
    <ta-cell label="count=8"><ta-rate count="8" /></ta-cell>
  </ta-group>
  <ta-group title="半星">
    <ta-cell label="modelValue=2.5"><ta-rate allow-half v-model="value" :count="count" /></ta-cell>
  </ta-group>
  <ta-group title="状态">
    <ta-cell label="只读"><ta-rate readonly :modelValue="3" /></ta-cell>
    <ta-cell label="禁用"><ta-rate disabled :modelValue="3" /></ta-cell>
  </ta-group>
  <ta-group title="事件监听">
    <ta-cell label="change"><ta-rate allow-half @change="onChange" /></ta-cell>
  </ta-group>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { showToast } from '@/index'

export default defineComponent({
  name: 'ExpRate',
  data() {
    return {
      count: 5,
      value: 2.5
    }
  },
  methods: {
    onChange(value: number) {
      showToast(`Value: ${value}`)
    }
  }
})
</script>

Import

js
import { TaRate } from 'tantalum-ui-mobile'

具体的引入方式可以参考引入组件

Props

属性类型默认值必填说明
v-modelnumber
namestring标识
countnumber | string5有 count 个星星,只支持 1~20 整数
allow-halfbooleanfalse是否允许半选
disabledbooleanfalse是否禁用
readonlybooleanfalse是否为只读状态
iconstring | Component'StarOutlined'默认图标,使用 Icon 组件
active-iconstring | Component'StarFilled'激活时图标,使用 Icon 组件
colorstring自定义默认态的图标颜色
active-colorstring自定义激活态的图标颜色
sizenumber | string自定义图标大小,单位 px

Events

事件描述回调函数参数
change点击星星时触发的事件( value: number )