@handcrafted-market/vue3-numeric

中文文档
1.0.4发布于 2022/03/30MITESM + CJS近 30 天下载 5816

Input field component to display currency value based on vue-numeric.

原始使用文档
文档目录16 节
  1. Installation
  2. CDN
  3. Usage
  4. Quick example
  5. Currency symbol
  6. Currency symbol Spacing
  7. Minimum & maximum constraint
  8. Disable/enable negative values
  9. Enable decimal precision
  10. Thousands separator
  11. Input placeholder when empty
  12. Value when empty
  13. Output Type
  14. Props
  15. License
  16. Recommended IDE Setup

vue3-numeric

npm npm npm npm

This is an implementation for Vue 3 of the Original project vue-numeric in its version 2.4.3.

It initially existed at https://github.com/flvportafolio/vue3-numeric but seems to have been deleted. Since it has an MIT license, it's been reuploaded here in the state that it last existed in our deployments. We may or may not be able to actually support issues that are raised for the project.

Installation

# NPM
$ npm install @handcrafted-market/vue3-numeric

CDN

<html>
  <head>
    <script src="https://unpkg.com/vue@next"></script>
  </head>
  <body>
    <div id="app">
       {{price}}
      <hr>
      <vue-numeric
        currency="$"
        separator=","
        v-model="price"
        :precision="2"
      ></vue-numeric>
    </div>
    <script src="https://unpkg.com/[email protected]/dist/vue3-numeric.umd.js"></script>
    <script type="module">
      const VueNumeric = window["vue3-numeric"];
      Vue.createApp({
        setup() {
          const price = Vue.ref("123");
          return { price };
        }
      })
      .component("vue-numeric", VueNumeric)
      .mount("#app");
    </script>
  </body>
</html>

Register globally

import { createApp } from 'vue';
import App from './App.vue';
import VueNumeric from 'vue3-numeric';

createApp(App)
  .component("vue-numeric", VueNumeric)
  .mount('#app');

Register as Component (Composition Api)

<script>
import { ref } from 'vue';
import VueNumeric from 'vue3-numeric';
export default {
  components: { VueNumeric },
  setup() {
    const price = ref('');
    return { price };
  },
};
</script>
<template>
  <vue-numeric
    separator=","
    v-model="price"
    :precision="2"
  ></vue-numeric>
</template>

Register as Component (Composition Api - setup sugar)

<script setup>
import { ref } from 'vue';
import VueNumeric from 'vue3-numeric';
const price = ref('');
</script>
<template>
  <vue-numeric
    separator=","
    v-model="price"
    :precision="2"
  ></vue-numeric>
</template>

Usage

Quick example

<script>
import { ref } from 'vue';
import VueNumeric from 'vue3-numeric';
export default {
  components: { VueNumeric },
  setup() {
    const price = ref('');
    return { price };
  },
};
</script>
<template>
  <vue-numeric
    currency="$" 
    separator=","
    v-model="price"
    :precision="2"
  ></vue-numeric>
</template>

Currency symbol

Set the currency prop to add a currency symbol within the input.

<vue-numeric currency="$"></vue-numeric>

Currency symbol Spacing

Set the currencySymbolSpacing prop to false to show $2.00. instead of $ 2.00. By default the value is true

<vue-numeric
  currency="$"
  :currencySymbolSpacing="false"
></vue-numeric>

Minimum & maximum constraint

Limit the minimum and maximum value by using min and max props.

  • min defaults to 0.
  • min and max accept String or Number values.
<vue-numeric v-bind:min="2000" v-bind:max="10000"></vue-numeric>

Disable/enable negative values

minus defaults to false (no negative numbers).

<vue-numeric v-bind:minus="false"></vue-numeric>

Enable decimal precision

By default the decimal value is disabled. To use decimals in the value, add the precision prop.

  • precision accept a String or Number numeric value.
<vue-numeric v-bind:precision="2"></vue-numeric>

Thousands separator

  • Default thousand separator's symbol is ,.
  • Use the separator prop to change the thousands separator.
  • separator only accepts space, , or ..
  • When using the . or space as thousand separator, the decimal separator will be ,.
<vue-numeric separator="."></vue-numeric>

Input placeholder when empty

<vue-numeric placeholder="only number allowed"></vue-numeric>

Value when empty

By default, when you clean the input the value is set to 0. You can change this value to fit your needs.

<vue-numeric :empty-value="1"></vue-numeric>

Output Type

By default the value emitted for the input event is of type Number. However you may choose to get a String instead by setting the property output-type to String.

<vue-numeric output-type="String"></vue-numeric>

Props

PropsDescriptionRequiredTypeDefault
currencyCurrency prefixfalseString-
currency-symbol-positionPosition of the symbol (accepted values: prefix or suffix)falseStringprefix
maxMaximum value allowedfalseNumber9007199254740991
minMinimum value allowedfalseNumber-9007199254740991
minusEnable/disable negative valuesfalseBooleanfalse
placeholderInput placeholderfalseString-
empty-valueValue when input is emptyfalseNumber0
output-typeOutput Type for input eventfalseStringString
precisionNumber of decimalsfalseNumber-
separatorThousand separator symbol (accepts space, . or ,)falseString,
decimal-separatorCustom decimal separatorfalseString-
thousand-separatorCustom thousand separatorfalseString-
read-onlyHide input field and show the value as textfalseBooleanfalse
read-only-classClass for read-only elementfalseString''

License

MIT license

版本与发布记录

@handcrafted-market/vue3-numeric 共发布 3 个版本,首次发布于 2022/03/30;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.4latest2022/03/304 年前
1.0.32022/03/304 年前
1.0.22022/03/304 年前

关于 @handcrafted-market/vue3-numeric 的常见问题

@handcrafted-market/vue3-numeric 是什么?

Input field component to display currency value based on vue-numeric.

如何安装 @handcrafted-market/vue3-numeric?

在项目目录运行 npm install @handcrafted-market/vue3-numeric,或使用 pnpm add / yarn add / bun add。

@handcrafted-market/vue3-numeric 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/handcrafted-market__vue3-numeric 是否存在。

@handcrafted-market/vue3-numeric 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@handcrafted-market/vue3-numeric 可以商用吗?

@handcrafted-market/vue3-numeric 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@handcrafted-market/vue3-numeric 的下载量有多少?

根据 npm 官方下载统计,@handcrafted-market/vue3-numeric 在 2026/10/17 – 2026/11/15 这 30 天内被下载 5,816 次,日均约 194 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@handcrafted-market/vue3-numeric 还在维护吗?

最新版本 1.0.4 发布于 2022/03/30(4 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/03/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。