使用a two-way filter,我们可以为单个分配aread 和 write操作,以在和之间filter更改相同数据的值。viewmodel
//JS Vue.filter('uppercase', { //read : model -> view read: function(value) { return value.toUpperCase(); }, //write : view -> model write: function(value) { return value.toLowerCase(); } }); /* * Base value of data: 'example string' * * In the view : 'EXAMPLE STRING' * In the model : 'example string' */