Vue.filter('howManyPeopleDiff', function (str) {
var perNum='';
if(str.search("1") != -1){
perNum+= 'a'
}
if(str.search("2") != -1){
perNum+= 'b'
}
if(str.search("3") != -1){
perNum += 'c'
}
if(str.search("4") != -1){
perNum += 'd'
}
if(str.search("5") != -1){
perNum+= 'e'
}
if(str.search("6") != -1){
perNum+= 'f'
}
return perNum;
});
return perNum
The return value of · For example,
- For example (call and corresponding return):,
{(1,2) | howManyPeopleDiff}
// returnab
{(3,4) | howManyPeopleDiff}
, // returncd
{(1,2,3,4) | howManyPeopleDiff}
// returnabcd
- and many more;
-
Blogger's own retention: call method, see the code file corresponding to the remark project file for details.
The above is all about "js judges whether the string contains a certain character? ".