<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="../vue.js"></script>
<style>
#app{
padding:52px;
}
.banner{
width: 600px;
height: 150px;
border-radius: 20px;
box-shadow: 5px 5px 10px #888888;
font-size: 32px;
font-weight: bolder;
text-align: center;
line-height: 150px;
background-color: blueviolet;
color: cornsilk;
margin:0px auto;
}
</style>
</head>
<body>
<div id="app">
<div class="banner">
{{ text | a }}
</div>
</div>
<script>
var vm=new Vue({
el:"#app",
data:{
text:"actions speak louder than words."
},
// 定义过滤器
filters:{
a:function(val){
var strs=val.split(" ")
var result="";
for (var index = 0; index < strs.length; index++) {
result+=strs[index].charAt(0).toUpperCase()+strs[index].substring(1)+"";
}
return result;
}
},
})
</script>
</body>
</html>
Vue的过滤器
最新推荐文章于 2024-02-20 00:00:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)