mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 08:12:49 +08:00
数字翻牌动态数据
This commit is contained in:
parent
5abfcfdd1b
commit
a5374ee746
@ -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') {
|
||||
|
Loading…
Reference in New Issue
Block a user