quick-admin-vue3-core
Version:
以快(计算机执行效率、开发效率)为核心的后台管理系统开发模板
51 lines (50 loc) • 1.62 kB
JavaScript
import { defineComponent as V, ref as b, computed as i, watch as h, createElementBlock as B, openBlock as w, toDisplayString as T, nextTick as k } from "vue";
import { T as E, a as $ } from "./index-9d6RO4hD.js";
const D = { class: "base-number" }, C = /* @__PURE__ */ V({
__name: "BaseNumber",
props: {
startValue: { default: 0 },
value: { default: (/* @__PURE__ */ new Date()).getFullYear() },
duration: { default: 1500 },
autoplay: { type: Boolean, default: !0 },
decimals: { default: 0 },
prefix: { default: "" },
suffix: { default: "" },
separator: { default: "," },
decimal: { default: "." },
useEasing: { type: Boolean, default: !0 },
transition: { default: "linear" }
},
setup(c) {
const e = c, s = b(e.startValue), d = i(() => e.useEasing ? E[e.transition] : void 0), f = $(s, {
disabled: !1,
duration: e.duration,
transition: d.value
}), p = i(() => m(f.value));
function m(u) {
const { decimals: r, decimal: v, separator: o, suffix: _, prefix: g } = e;
let a = u.toFixed(r);
a = String(a);
const n = a.split(".");
let t = n[0];
const y = n.length > 1 ? v + n[1] : "", l = /(\d+)(\d{3})/;
if (o)
for (; l.test(t); )
t = t.replace(l, `$1${o}$2`);
return g + t + y + _;
}
async function x() {
await k(), s.value = e.value;
}
return h(
[() => e.startValue, () => e.value],
() => {
e.autoplay && x();
},
{ immediate: !0 }
), (u, r) => (w(), B("span", D, T(p.value), 1));
}
});
export {
C as default
};