过滤器
2020-07-08 本文已影响0人
琳媚儿
过滤文字
判断名字小于10个就为空。否则就显示三个点
<div class="goods_title">{{product_name | nameFilter}}</div>
<div class="goods_title2">{{sku_name | nameFilter}} {{specification_item_names?specification_item_names:'' | nameFilter}}</div>
filters:{
nameFilter(name){
if(name.length<10){
return name
}else{
return name.substring(0,9)+'...'
}
}
},
手机号脱敏
<div>手机号码 {{ phonenum | phonenumEncryption }}</div>
filters: {
//手机号脱敏显示
phonenumEncryption(val) {
return val.substr(0, 3) + '****' + val.substr(7, 11);
}
},