File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 6
6
<p >helloMsg: {{helloMsg}}</p >
7
7
<p >computed msg: {{computedMsg}}</p >
8
8
<button @click =" greet" >Greet</button >
9
+ <hello ref =" helloComponent" ></hello >
9
10
</div >
10
11
</template >
11
12
12
13
<script lang="ts">
13
14
import Vue from ' vue'
14
15
import Component from ' ../lib/index'
16
+ import Hello from ' ./Hello.vue' ;
15
17
16
18
@Component ({
17
19
props: {
18
20
propMessage: String
21
+ },
22
+ components: {
23
+ Hello
19
24
}
20
25
})
21
26
export default class App extends Vue {
27
+ // props have to be declared for typescript
22
28
propMessage: string
23
29
24
30
// inital data
@@ -40,6 +46,12 @@ export default class App extends Vue {
40
46
// method
41
47
greet () {
42
48
alert (' greeting: ' + this .msg )
49
+ this .$refs .helloComponent .sayHello ()
50
+ }
51
+
52
+ // dynamic component
53
+ $refs: {
54
+ helloComponent: Hello
43
55
}
44
56
}
45
57
</script >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" hello" >
3
+ <h1 >Hello Times: {{ helloTimes }}</h1 >
4
+ </div >
5
+ </template >
6
+
7
+ <script lang="ts">
8
+ import Vue from ' vue'
9
+ import Component from ' ../lib/index'
10
+
11
+ @Component
12
+ export default class Hello extends Vue {
13
+ helloTimes: number = 0
14
+ sayHello() {
15
+ this .helloTimes ++ ;
16
+ }
17
+ }
18
+ </script >
19
+
You can’t perform that action at this time.
0 commit comments