@onecoffee/coffeeutils

1.0.20 • Public • Published

金额、数量处理方法汇总

1. 金额、数量千分位格式化 (formatAmount)

工具方法安装

yarn add @onecoffee/coffeeutils

全局注册

// main.js

import { moneyUtils } from '@onecoffee/coffeeutils'
Vue.prototype.$moneyUtils = moneyUtils

方法说明

/**
 * 金额、数量千分位格式处理
 * 函数名:formatAmount
 * @param { value } arg1   // 待处理金额、数量
 * @param { decimal } arg2 // 小数位数,非必须参数,默认2位
 */

方法全局使用

方式1: 直接返回千分位格式数据
this.$moneyUtils.formatAmount(value)

// 123,456.77

方式2:计算属性或其他方式
computed: {
    formatAmount() {
        return value => this.$moneyUtils.formatAmount(value)
    }
},

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @onecoffee/coffeeutils

      Weekly Downloads

      0

      Version

      1.0.20

      License

      ISC

      Unpacked Size

      10.1 kB

      Total Files

      7

      Last publish

      Collaborators

      • wujiedage
      • liping1.chen
      • di.zhao
      • panwenda
      • cqyu
      • qiang.shen