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 66 <p >helloMsg: {{helloMsg}}</p >
77 <p >computed msg: {{computedMsg}}</p >
88 <button @click =" greet" >Greet</button >
9+ <hello ref =" helloComponent" ></hello >
910 </div >
1011</template >
1112
1213<script lang="ts">
1314import Vue from ' vue'
1415import Component from ' ../lib/index'
16+ import Hello from ' ./Hello.vue' ;
1517
1618@Component ({
1719 props: {
1820 propMessage: String
21+ },
22+ components: {
23+ Hello
1924 }
2025})
2126export default class App extends Vue {
27+ // props have to be declared for typescript
2228 propMessage: string
2329
2430 // inital data
@@ -40,6 +46,12 @@ export default class App extends Vue {
4046 // method
4147 greet () {
4248 alert (' greeting: ' + this .msg )
49+ this .$refs .helloComponent .sayHello ()
50+ }
51+
52+ // dynamic component
53+ $refs: {
54+ helloComponent: Hello
4355 }
4456}
4557 </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