forked from ygs-code/vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
11标签匹配.html
62 lines (55 loc) · 1.45 KB
/
11标签匹配.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
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="vue.js"></script>
</head>
<body>
<div id="app">
<div :class="{'a':message}">
{{message}}
</div>
</div>
<script>
// 注册一个全局自定义指令 `v-focus`
Vue.directive('info', {
// 当被绑定的元素插入到 DOM 中时……
inserted: function (el) {
el.addEventListener('change',function () {
console.log(this.value)
},false)
// // 聚焦元素
// el.focus()
}
})
// 注册一个全局自定义指令 `v-focus`
Vue.directive('data', {
// 当被绑定的元素插入到 DOM 中时……
inserted: function (el) {
el.addEventListener('change',function () {
console.log(this.value)
},false)
// // 聚焦元素
// el.focus()
}
})
new Vue(
{
el:'#app',
// comments:true,
data: {
message: 'Hello'
},
directives: {
focus: {
// 指令的定义
inserted: function (el) {
el.focus()
}
}
}
})
</script>
</body>
</html>