Skip to content
目录

rate Rating

for rating or giving stars

1.basic usage

binding a value using v-model

vue
<template>
  <dk-rate v-model="checked"></dk-rate>
</template>
<script>
  import { defineComponent, reactive, toRefs } from 'vue'
  export default defineComponent({
    name: 'RateComp',
    setup() {
      const data = reactive({
        checked: 1
      })
      return {
        ...toRefs(data)
      }
    }
  })
</script>
展开

2.custom color

select-color property can configure the color of the stars when selected, and the no-select-color property can configure the color of the stars when not selected.

vue
<template>
    <dk-rate 
      v-model="checked1" 
      :select-color="'red'" 
      :no-select-color="'#26BF8C'">
    </dk-rate>
  </template>
  <script>
    import { defineComponent, reactive, toRefs } from 'vue'
    export default defineComponent({
      name: 'RateComp',
      setup() {
        const data = reactive({
          checked1: 2
        })
        return {
          ...toRefs(data)
        }
      }
    })
  </script>
展开

3.custom icon

icon property can be used to customize the icon (currently only supports icons from the ICON component library).

vue
<template>
    <dk-rate 
      v-model="checked1" 
      :icon="'IconAndroid'"
    >
    </dk-rate>
  </template>
  <script>
    import { defineComponent, reactive, toRefs } from 'vue'
    export default defineComponent({
      name: 'RateComp',
      setup() {
        const data = reactive({
          checked1: 2
        })
        return {
          ...toRefs(data)
        }
      }
    })
  </script>
展开

4.icon size

iconSize property can define the size of the icon.小

vue
<template>
    <dk-rate 
      v-model="checked2" 
      :iconSize="35"
      :icon="'IconAndroid'"
    >
    </dk-rate>
  </template>
  <script>
    import { defineComponent, reactive, toRefs } from 'vue'
    export default defineComponent({
      name: 'RateComp',
      setup() {
        const data = reactive({
          checked2: 2
        })
        return {
          ...toRefs(data)
        }
      }
    })
  </script>
展开

5.whether it is disabled

readonly determines whether the rating is disabled. It accepts true or false values.

vue
<template>
    <dk-rate 
      v-model="checked3" 
      :readonly='true'
    >
    </dk-rate>
  </template>
  <script>
    import { defineComponent, reactive, toRefs } from 'vue'
    export default defineComponent({
      name: 'RateComp',
      setup() {
        const data = reactive({
          checked3: 2
        })
        return {
          ...toRefs(data)
        }
      }
    })
  </script>
展开

6.listen to events

onchange listen to events

vue
<template>
    <dk-rate 
      v-model="checked4" 
      :onchange="setFunctionProps"
    >
    </dk-rate>
  </template>
  <script>
    import { defineComponent, reactive, toRefs } from 'vue'
    export default defineComponent({
      name: 'RateComp',
      setup() {
        const data = reactive({
          checked4: 2
        })
        const methods = reactive({
          setFunctionProps(item) {
           alert(item)
          }
        })
        return {
          ...toRefs(data),
          ...toRefs(methods)
        }
      }
    })
  </script>
展开

property

parameterdescriptiontypepossible valuesdefault value
v-modelbound valuestring number--
select-colorselected colorstring-#fcc202
no-select-colorunselected colorstring-#5E5E5E
iconcustom iconstring-IconAndroid
iconSizeicon sizestring number-20
readonlywhether disabledbooleantrue false-

event

event namedescriptioncallback parameters
changetriggered when the bound value changes() => number

Contributors