v-money

WebJar for v-money

License

License

MIT
Categories

Categories

JavaScript Languages Github Development Tools Version Controls
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

github-com-vuejs-tips-v-money
Last Version

Last Version

0.8.1
Release Date

Release Date

Type

Type

jar
Description

Description

v-money
WebJar for v-money
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/vuejs-tips/v-money

Download github-com-vuejs-tips-v-money

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/github-com-vuejs-tips-v-money/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>github-com-vuejs-tips-v-money</artifactId>
    <version>0.8.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-vuejs-tips-v-money/
implementation 'org.webjars.npm:github-com-vuejs-tips-v-money:0.8.1'
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-vuejs-tips-v-money/
implementation ("org.webjars.npm:github-com-vuejs-tips-v-money:0.8.1")
'org.webjars.npm:github-com-vuejs-tips-v-money:jar:0.8.1'
<dependency org="org.webjars.npm" name="github-com-vuejs-tips-v-money" rev="0.8.1">
  <artifact name="github-com-vuejs-tips-v-money" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='github-com-vuejs-tips-v-money', version='0.8.1')
)
libraryDependencies += "org.webjars.npm" % "github-com-vuejs-tips-v-money" % "0.8.1"
[org.webjars.npm/github-com-vuejs-tips-v-money "0.8.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

v-money Mask for Vue.js

The Mask Money

Features

  • Lightweight (<2KB gzipped)
  • Dependency free
  • Mobile support
  • Component or Directive flavors
  • Accept copy/paste
  • Editable

For other types of mask, use vue-the-mask

Usage

A. Globally

import Vue from 'vue'
import money from 'v-money'

// register directive v-money and component <money>
Vue.use(money, {precision: 4})

B. Use as component: https://jsfiddle.net/auom8st8/

<template>
  <div>
    <money v-model="price" v-bind="money"></money> {{price}}
  </div>
</template>

<script>
  import {Money} from 'v-money'

  export default {
    components: {Money},

    data () {
      return {
        price: 123.45,
        money: {
          decimal: ',',
          thousands: '.',
          prefix: 'R$ ',
          suffix: ' #',
          precision: 2,
          masked: false
        }
      }
    }
  }
</script>

C. Use as directive: https://jsfiddle.net/nj3cLoum/2/

Must use vmodel.lazy to bind works properly.

<template>
  <div>
    <input v-model.lazy="price" v-money="money" /> {{price}}
  </div>
</template>

<script>
  import {VMoney} from 'v-money'

  export default {
    data () {
      return {
        price: 123.45,
        money: {
          decimal: ',',
          thousands: '.',
          prefix: 'R$ ',
          suffix: ' #',
          precision: 2,
          masked: false /* doesn't work with directive */
        }
      }
    },

    directives: {money: VMoney}
  }
</script>

Properties

property Required Type Default Description
precision true Number 2 How many decimal places
decimal false String "." Decimal separator
thousands false String "," Thousands separator
prefix false String "" Currency symbol followed by a Space, like "R$ "
suffix false String "" Percentage for example: " %"
masked false Boolean false If the component output should include the mask or not

References

org.webjars.npm

Vue.js Tips

Learn Vue.js by building real world components

Versions

Version
0.8.1