-
Notifications
You must be signed in to change notification settings - Fork 3
/
directive.html
42 lines (38 loc) · 1.06 KB
/
directive.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<meta name="viewport" content="minimal-ui,width=device-width,initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=no" />
<title>Directive</title>
<script src="vue.js"></script>
</head>
<body>
<div id="app">
<span v-custom-directive="message">{{ message | reverse }}</span>
</div>
<script>
Vue.directive('custom-directive', {
bind: function(el, binding, vnode) {
console.log('bind');
console.log(el);
console.log(binding);
},
update: function(value) {
console.log(value);
},
unbind: function() {},
inserted: function(el) {
}
});
Vue.filter('reverse', function (value) {
return value.split('').reverse().join('')
});
var app = new Vue({
el: '#app',
data: {
message: 'Hello Directive!'
}
});
</script>
</body>
</html>