[Vuejs]-Vue custom filter does not work when defined globally

0👍

You should remove the currencyDisplay key from the global filter:

Vue.filter('currencyDisplay', {
  read: function (val) {
    return '$' + val.toFixed(2)
  },
  write: function (val, oldVal) {
    var number = +val.replace(/[^\d.]/g, '')
    return isNaN(number) ? 0 : number
  }
})

Leave a comment