For a simple example: textbox to input currency data. The requirement is to display user input in \"$1,234,567\" format and remove decimal point.
I have tried vue direct
I implemented a component. According to Mani's answer, it should use $emit.
Vue.component('currency', {
template: '',
props: ['placeholder', 'title', 'value'],
computed: {
formatted: {
get: function () {
var value = this.value;
var formatted = currencyFilter(value, "", 0);
return formatted;
},
set: function (newValue) {
var cleanValue = newValue.replace(",", "");
var intValue = parseInt(cleanValue, 10);
this.value = 0;
this.value = intValue;
}
}
}
}
);