<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="vue.js"></script>
</head>
<body>
<div id="app">
{{ message | firstUpper() }}
</div>
<script>
// 全局注册过滤器一定要在Vue实例之前
Vue.filter("firstUpper",function (val) {
return val.charAt(0).toUpperCase()+val.slice(1)
})
new Vue({
el:'#app',
data:{
message:'abc'
}
})
</script>
</body>
</html>
网友评论