-
Notifications
You must be signed in to change notification settings - Fork 0
/
components-inline.html
63 lines (61 loc) · 1.74 KB
/
components-inline.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
63
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.global.js"></script>
</head>
<body>
<div id="app">
<posts v-slot="vm">
<h1 @click="vm.display">Click me (Options API)</h1>
</posts>
</div>
<div id="app2">
<posts v-slot="vm">
<h1 @click="vm.display">Click me (Composition API)</h1>
</posts>
</div>
<script>
// Default Slot - Options API
let app = Vue.createApp({
components: {
posts: {
template: `<div><slot v-bind="self"/></div>`,
data() {
return {
}
},
computed: {
self() {
return this;
},
},
methods: {
display() {
console.log('hello')
}
}
}
}
}).mount('#app')
// Default Slot - Composition API
let app2 = Vue.createApp({
components: {
posts: {
template: `<div><slot v-bind="self"/></div>`,
setup(props, context) {
return {
self: {
display: () => {
console.log('hello')
}
}
}
}
}
}
}).mount('#app2')
</script>
</body>
</html>