0👍
Here is what worked for me:
- I created the “createNumberMask” function in the “data()” section of the vue component
NumberMaskTestComponent.js file
import MaskedInput from 'vue-text-mask';
import createNumberMask from 'text-mask-addons/dist/createNumberMask';
export default Vue.component('number-mask-test-component', {
name: 'NumberMaskTestComponent',
data () {
return {
numberMask: createNumberMask({
prefix: '$',
allowDecimal: true,
decimalLimit: 2,
integerLimit: 1
}),
testNumber: '123.3445'
}
},
components: {
MaskedInput
}
})
NumberMaskTestComponent.vue file
<template>
<div>
<masked-input
type="text"
name="numberTest"
class="form-control"
v-model="testNumber"
:mask="numberMask"
:guide="false"
placeholderChar="#">
</masked-input>
</div>
</template>
<script lang="ts" src="./NumberMaskTestComponent.js">
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
👤aero
- [Vuejs]-Vue 2 call method in v-for performance issue
- [Vuejs]-How to change data property in Vuejs using axios when a post request is slow?
Source:stackexchange.com