-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path05-Directives.html
58 lines (36 loc) · 959 Bytes
/
05-Directives.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
<html>
<head>
<script src="https://unpkg.com/vue"></script>
<title>Directives</title>
<!-- https://vuejs.org/guide/reusability/custom-directives.html -->
</head>
<body>
<div id="app">
<h1>Directives</h1>
<input v-focus>
<alert-box></alert-box>
</div>
</body>
</html>
<script type="text/javascript">
const app = Vue.createApp({});
// Register a global custom directive called `v-focus`
app.directive('focus', {
mounted: function(el) {
el.focus();
},
});
app.component('alert-box', {
template: `<p v-alert>Black Alert!!</p>`,
directives: {
alert: {
beforeMount(el) {
console.log('beforeMount el', el);
}
}
}
});
app.mount("#app");
</script>
<!-- livereload -->
<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>