过滤器filter
自定义过滤器
Vue.filter("过滤器名称",function(){
//过滤器业务逻辑
})
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id = "app">
<div>
<input type="text" v-model= 'msg'>
</div>
<div><span>{{msg | upper}}</span></div>
<div><span>{{msg | lower}}</span></div>
</div>
<script src="js/vue.js"></script>
<script>
Vue.filter('upper',function(val) {
return val.charAt(0).toUpperCase() +val.slice(1);
});
Vue.filter('lower',function(val){
return val.charAt(0).toLowerCase() +val.slice(1);
});
var vm = new Vue({
el:'#app',
data:{
msg :''
},
})
</script>
</body>
</html>