-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy path20.通过过滤器写回数据.html
52 lines (51 loc) · 1.21 KB
/
20.通过过滤器写回数据.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
<!--{{capitalize | capitalize 5}}-->
<input type="text" v-model="capitalize | cap 5">
{{capitalize}}
</div>
<script src="vue.js"></script>
<script>
Vue.filter('cap', {
read: function (val,begin,end) {
return val.slice(0,begin).toUpperCase()
},
write: function (val) {
console.log(val);
//当我们input标签写入内容的时候 会默认调用write方法
return val+100;
}
});
var vm = new Vue({
el:"#app",
data:{
capitalize:'abcdefghijq',
count:0,
flag:-1,
json:{name:1},
arr:[
{name:'jw1',age:1},
{name:'jw2'},
{name:'jw3'},
{name:'jw4',age:1},
{name:'jw5'},
{name:'jw6'},
{name:'jw7',age:1},
{name:'jw8'},
{name:'jw9'},
{name:'jw10'},
{name:'jw11'},
{name:'jw12'},
{name:'jw13'},
]
}
})
</script>
</body>
</html>