Closed

Description
http://vuejs.org/guide/custom-filter.html#Two-way_Filters
This doesn't work.
Vue.filter('currencyDisplay', {
currencyDisplay: {
// model -> view
// formats the value when updating the input element.
read: function(val) {
return '$'+val.toFixed(2)
},
// view -> model
// formats the value when updating the data.
write: function(val, oldVal) {
var number = +val.replace(/[^\d.]/g, '')
return isNaN(number) ? 0 : number
}
}
})
This is work.
Vue.filter('currencyDisplay', {
// model -> view
// formats the value when updating the input element.
read: function(val) {
return '$'+val.toFixed(2)
},
// view -> model
// formats the value when updating the data.
write: function(val, oldVal) {
var number = +val.replace(/[^\d.]/g, '')
return isNaN(number) ? 0 : number
}
}
})
Metadata
Metadata
Assignees
Labels
No labels