Vue-filters



{{name | upperCase(true)}}
,
filters:{
upperCase:function(val,isFirstWord){
var s = val.toString();
if(isFirstWord){
return val.charAt(0).toUpperCase()+val.slice(1);
}else{
return val.toUpperCase();
}
}
}


<div v-bind:title="msg|UpFirstChar">{{msg}}</div><br/>
<div v-bind:title="msg|UpFirstChar|removeSpace">{{msg}}</div>

filters:{
UpFirstChar:function(v){
v= v.toString();
var arr = v.split(" ");
var newarr = arr.map(function(item){
return item.charAt(0).toUpperCase()+item.slice(1);
});
return newarr.join(" ");
}
,removeSpace:function(val){
return val.toString().replace(/ /g,"");
}}

评论

此博客中的热门博文

XML, XSL, HTML

Input in element.eleme.io

Data URI是由RFC 2397 ACE