-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.vue
36 lines (31 loc) · 926 Bytes
/
setup.vue
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
<template>
<div>{{ collectionName }}: {{ readersNumber }} {{ book.title }}</div>
</template>
<script>
import { h, toRefs, toRef, ref, reactive, } from 'vue'
// import { ref, reactive } from 'vue'
// import { toRef } from 'vue'
export default {
props: {
collectionName: String
},
setup(props, context) {
const title = toRef(props, 'title')
// Attributes (Non-reactive object)
console.log(context.attrs)
// Slots (Non-reactive object)
console.log(context.slots)
// Emit Events (Method)
console.log(context.emit)
const readersNumber = ref(0)
const book = reactive({ title: 'Vue 3 Guide' })
// expose to template
// return {
// readersNumber,
// book
// }
// Please note that we need to explicitly expose ref value here
return () => h('div', [readersNumber.value, book.title])
}
}
</script>