I have implemented a component. According to Mani's answer, he should use $ emit.
Vue.component('currency', { template: '<input type="text"' + ' class="form-control"' + ' :placeholder="placeholder""' + ' :title="title"' + ' v-model="formatted" />', 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; } } } }
);
flyfrog
source share