filter(过滤器)
Vue.js 允许你自定义过滤器,可被用于一些常见的文本格式化
局部过滤器:filters
1 <span>{{age|changAge(‘特别‘)}}</span> 2 3 filters:{ 4 changAge(age,f){ 5 if (age==18){ 6 return f+‘年轻‘ 7 } 8 } 9 }
filters与methods为同一级别,所以定义时单独和methods并列写,过滤器接受在管道符前和管道费符后方法名后传递入参
原文:https://www.cnblogs.com/bugoobird/p/13205179.html