UNPKG

@wfrog/vc

Version:

`自用` 的基于 `element-plus` 二次封装的 `vue3` 组件库。追求在业务场景中,尽可能使用更少的代码量来实现需求。 因此在组件封装上,以 `方便` 为主,打包仅 `esm` 模式。

39 lines (38 loc) 1.45 kB
// src/directives/thousand/index.ts import { loader } from "@wfrog/utils"; var thousand = { mounted: async (el, binding) => { const elInput = el.getElementsByTagName("input")[binding.value?.elInputIndex || 0] || el.getElementsByTagName("input")[0]; const disabled = elInput.disabled; elInput.disabled = true; el.classList.add("is-disabled"); const Cleave = await loader.loadCdnSingle("cleave"); const option = { decimalScale: 2, integerScale: 0, prefix: "", ...binding.value }; elInput.cleave = new Cleave(elInput, { numeral: true, numeralThousandsGroupStyle: "thousand", numeralDecimalScale: option.decimalScale, numeralIntegerScale: option.integerScale, prefix: option.prefix }); elInput.style.textAlign = "right"; elInput.style.fontFamily = "Pathway Gothic One"; elInput.value = elInput.cleave?.properties?.result || ""; el.classList.remove("is-disabled"); elInput.disabled = disabled; }, updated: (el, binding) => { setTimeout(() => { const event = new Event("input", { bubbles: true }); const elInput = el.getElementsByTagName("input")[binding.value?.elInputIndex || 0] || el.getElementsByTagName("input")[0]; elInput.dispatchEvent(event); if (elInput.cleave) { elInput.value = elInput.cleave?.properties?.result || ""; } }, 0); } }; var thousand_default = thousand; export { thousand_default as default };