用于以美观的方式展示一组数值及其标题的组件,支持小数点分隔显示,可以自适应不同数量的数值项,并支持点击事件。
import CNumerical from '@components/layout/numerical';
values
(Array,必选):数值集合,数组中的每项为对象,包含以下属性:title
(String):数值项的标题value
(Number|String):要显示的数值textType
(String,可选):文本颜色类型,对应 CSS 类 'm-text-{textType}'onClick
(Function,可选):点击数值项时的回调函数,接收当前项对象作为参数<template>
<view class="page">
<CNumerical :values="numericalValues" />
</view>
</template>
<script>
import CNumerical from '@components/layout/numerical';
export default {
components: {
CNumerical
},
data() {
return {
numericalValues: [
{
title: '今日销量',
value: 135
},
{
title: '月销量',
value: 3254
},
{
title: '总销量',
value: 58962
}
]
}
}
}
</script>
<template>
<view class="page">
<CNumerical :values="numericalValues" />
</view>
</template>
<script>
import CNumerical from '@components/layout/numerical';
export default {
components: {
CNumerical
},
data() {
return {
numericalValues: [
{
title: '收入(元)',
value: 9856.75,
textType: 'primary'
},
{
title: '支出(元)',
value: 4328.50,
textType: 'warning'
},
{
title: '详情',
value: 0,
onClick: (item) => {
console.log('用户点击了详情');
// 跳转到详情页或显示详情弹窗
}
}
]
}
}
}
</script>