Skip to content

Instantly share code, notes, and snippets.

@cezarpretto
Created April 26, 2018 20:40
Show Gist options
  • Select an option

  • Save cezarpretto/d9f9c0ae5d2e7b57f0d343d4b5827f70 to your computer and use it in GitHub Desktop.

Select an option

Save cezarpretto/d9f9c0ae5d2e7b57f0d343d4b5827f70 to your computer and use it in GitHub Desktop.
<template>
<div id="inputMoney">
<money
id="txt1"
class="form-control"
v-model="price"
v-bind:placeholder="placeholder"
:disabled="disabled"
v-bind="money"
@input="change"
@keydown.enter="onEnter"
/>
<span v-bind:class="icon"></span>
</div>
</template>
<script type="text/javascript">
import { Money } from 'v-money'
export default {
name: 'input-money',
props: {
value: [String, Number],
placeholder: String,
icon: String,
disabled: [String, Boolean],
prefix: {
type: String,
default: 'R$ '
}
},
data () {
return {
price: this.value,
money: {
decimal: ',',
thousands: '.',
prefix: this.prefix,
suffix: '',
precision: 2,
masked: false
}
}
},
methods: {
onEnter () {
this.$emit('on-enter')
},
change () {
this.$emit('input', this.price)
}
},
components: {
Money
},
watch: {
value (vl) {
this.price = vl
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment