Vue中filters的使用
1.全局过滤器
Vue.filter('dataFormat',function(){
return data + 'filters数据'
})
2. 局部过滤器
filters: {
dataFormat(msg) {
if(msg === 'filters') {
return 'xxxxx';
} else {
return msg + 'yyy'
}
}
}
使用
<div>{{ msg | dataFormat }}</div>