UNPKG

@zhsz/cool-design-dv

Version:

93 lines (92 loc) 2.53 kB
import { defineComponent, useAttrs, computed, openBlock, createElementBlock, normalizeClass, createVNode, normalizeProps, guardReactiveProps, unref, createSlots, withCtx, Fragment, renderList, toDisplayString } from "vue"; import _sfc_main$1 from "./baseNumber.vue.mjs"; import "./style.css"; const __default__ = defineComponent({ name: "DvNumber", inheritAttrs: false }); const _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: { background: Boolean, // 数字 value: [Number, String], // 默认值 defaultValue: { type: [Number, String], default: 0 }, // CountUp配置参数对象 countUp: { type: [Boolean, Object] }, // 趋势 trend: { type: String, validator(val) { return ["up", "down", "-"].includes(val); } }, // 精度,保留几位小数 precision: { type: Number, default: 0 }, // 分隔符 separator: { type: String, default: "," }, // 前缀 prefix: { type: String }, // 后缀 suffix: String, // 按百分比计算显示 percentage: Boolean, // 前缀 和 后缀采用下标显示 sup: Boolean }, setup(__props) { const props = __props; const $attrs = useAttrs(); const classes = computed(() => { return { "is-background": props.background }; }); function getArray(value) { const array = String(value).split(""); return array.map((n) => { return { value: n, number: !Number.isNaN(Number.parseInt(n)) }; }); } return (_ctx, _cache) => { return openBlock(), createElementBlock("div", { class: normalizeClass(["my-dv-number", classes.value]) }, [ createVNode(_sfc_main$1, normalizeProps(guardReactiveProps({ ...unref($attrs), ...props })), createSlots({ _: 2 }, [ __props.background ? { name: "default", fn: withCtx(({ displayValue }) => [ (openBlock(true), createElementBlock(Fragment, null, renderList(getArray(displayValue), (item, index) => { return openBlock(), createElementBlock("span", { key: index, class: normalizeClass({ "is-number": item.number }) }, toDisplayString(item.value), 3); }), 128)) ]), key: "0" } : void 0 ]), 1040) ], 2); }; } }); export { _sfc_main as default };