-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprops-child.vue
45 lines (40 loc) · 930 Bytes
/
props-child.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
37
38
39
40
41
42
43
44
45
<script lang="ts">
import { type Count } from './props-parent.vue';
import { Setup, Define } from 'vue-class-setup';
@Setup
class Child<T, T2> extends Define<Props, Emits> {
public name = 'child';
get text() {
return 'child:' + this.count.value;
}
}
@Setup
class App extends Define<Props, Emits> {
public child = new Child();
public name = 'app';
public get text() {
return 'root:' + this.count.value;
}
public add() {
this.$emit('add');
}
}
</script>
<script lang="ts" setup>
export interface Props {
count: Count;
}
export interface Emits {
(event: 'add'): void;
}
defineProps<Props>();
defineEmits<Emits>();
const app = new App();
</script>
<template>
<div>
<p class="root-text">{{ app.text }}</p>
<p class="child-text">{{ app.child.text }}</p>
<button class="child-btn" @click="app.add()">Add</button>
</div>
</template>