Skip to content

排名轮播表

排名轮播表

基础用法

查看代码
vue
<template>
  <div w50rem h24rem p3 flex="~ col" justify-center items-center bg-dark>
    <div>
      <dv-scroll-ranking-board :config="config" style="width:500px;height:300px" />
    </div>
    <div pt5>
      <button btn @click="addData">
        增加数据
      </button>
    </div>
  </div>
</template>
<script setup>
const config = reactive({
  data: [
    {
      name: '周口',
      value: 55,
    },
    {
      name: '南阳',
      value: 120,
    },
    {
      name: '西峡',
      value: 78,
    },
    {
      name: '驻马店',
      value: 66,
    },
    {
      name: '新乡',
      value: 80,
    },
    {
      name: '信阳',
      value: 45,
    },
    {
      name: '漯河',
      value: 29,
    },
  ],
  unit: '万元',
})

const addData = () => {
  config.data.push({
    name: `新增城市${Math.floor(Math.random() * 100)}`,
    value: Math.floor(Math.random() * 100),
  })
}
</script>

config属性

参数说明类型可选值默认值
data表数据Array<Object>data属性[]
rowNum表行数Number---5
waitTime轮播时间间隔(ms)Number---2000
carousel轮播方式String'single'/'page''single'
unit数值单位String---''
sort自动排序Boolean---true
valueFormatter数值格式化Function---undefined
textColor1.4.2文字颜色String---#fff
color1.4.2主要颜色,包括柱颜色和排名颜色String---#1370fb
fontSize1.4.2字体大小Number---13

data属性

参数说明类型可选值默认值
name名称String------
value数值Number------

valueFormatter属性

参数说明类型可选值默认值
name名称String------
value数值Number------
percent百分比Number------
ranking排名Number------

TIP

name属性使用v-html进行渲染,因此你可以使用html标签来定制个性化的name展示效果。