数字翻牌动态数据

This commit is contained in:
ryker 2022-06-13 18:04:01 +08:00
parent 5abfcfdd1b
commit a5374ee746

View File

@ -6,13 +6,8 @@
</span>
</template>
<span :style="`color:${numberColor};font-size:${numberSize}px`">
<n-number-animation
:from="from"
:to="to"
:duration="dur * 1000"
:show-separator="showSeparator"
:precision="precision"
></n-number-animation>
<n-number-animation :from="option.from" :to="option.to" :duration="dur * 1000" :show-separator="showSeparator"
:precision="precision"></n-number-animation>
</span>
<template #suffix>
<span :style="`color:${suffixColor};font-size:${numberSize}px`">
@ -23,8 +18,10 @@
</template>
<script setup lang="ts">
import { PropType, toRefs } from 'vue'
import { PropType, toRefs, ref, reactive, watch } from 'vue'
import { CreateComponentType } from '@/packages/index.d'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { useChartDataFetch } from '@/hooks'
const props = defineProps({
chartConfig: {
@ -32,21 +29,44 @@ const props = defineProps({
required: true,
},
})
const option = reactive({
from: 0,
to: 0,
})
const { w, h } = toRefs(props.chartConfig.attr)
const {
let {
dur,
showSeparator,
prefixText,
prefixColor,
suffixText,
suffixColor,
from,
to,
precision,
numberSize,
numberColor,
} = toRefs(props.chartConfig.option)
const updateNumber = (newData: number) => {
//
option.from = option.to
option.to = newData
}
watch(
() => props.chartConfig.option.from,
() => {
option.from = props.chartConfig.option.from
}, { immediate: true }
)
watch(
() => props.chartConfig.option.to,
() => {
option.to = props.chartConfig.option.to
}, { immediate: true }
)
useChartDataFetch(props.chartConfig, useChartEditStore, updateNumber)
</script>
<style lang="scss" scoped>
@include go('decorates-number') {