-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvue8.html
More file actions
54 lines (48 loc) · 1.35 KB
/
Copy pathvue8.html
File metadata and controls
54 lines (48 loc) · 1.35 KB
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
53
54
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Vue 示例</title>
</head>
<body>
<div id="app">
<input type="text" v-focus />
<div v-test:msg.a.b="message"></div>
<div v-helloworld='{ msg:"hello", name: "Aresn" }'></div>
</div>
<script src="https://unpkg.com/vue/dist/vue.min.js" ></script>
<script>
Vue.directive('focus', {
inserted: function(el){
el.focus();
console.log('-----')
}
});
Vue.directive('test', {
bind: function(el, binding, vnode) {
var keys = [];
for(var i in vnode){
keys.push(i);
}
el.innerHTML =
'name: ' + binding.name + '<br/>' +
'value: ' + binding.value + '<br/>' +
'expression: ' + binding.expression + '<br/>' +
'argument: ' + binding.arg + '<br/>'
}
});
Vue.directive('helloworld', {
bind: function(el, binding, vnode) {
console.log(binding.value.msg);
console.log(binding.value.name);
}
});
var app = new Vue({
el: '#app',
data: {
message: "some text"
}
})
</script>
</body>
</html>