Created
April 26, 2018 20:40
-
-
Save cezarpretto/d9f9c0ae5d2e7b57f0d343d4b5827f70 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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