-
Notifications
You must be signed in to change notification settings - Fork 433
chore(example): add child component #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,19 +6,25 @@ | |
<p>helloMsg: {{helloMsg}}</p> | ||
<p>computed msg: {{computedMsg}}</p> | ||
<button @click="greet">Greet</button> | ||
<hello ref="helloComponent"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing closing tag 👀 |
||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
import Component from '../lib/index' | ||
import Hello from './Hello.vue'; | ||
|
||
@Component({ | ||
props: { | ||
propMessage: String | ||
}, | ||
components: { | ||
Hello | ||
} | ||
}) | ||
export default class App extends Vue { | ||
// props are had to declare again | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't it grammatically invalid that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, my fault. 😆 I'll fix it now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it looks great 👍 |
||
propMessage: string | ||
|
||
// inital data | ||
|
@@ -40,6 +46,12 @@ export default class App extends Vue { | |
// method | ||
greet () { | ||
alert('greeting: ' + this.msg) | ||
this.$refs.helloComponent.sayHello() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this causes compile error since all There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ktsn helloComponent is decalred as Hello (see line 54) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I thought |
||
} | ||
|
||
// dynamic component | ||
$refs: { | ||
helloComponent: Hello | ||
} | ||
} | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<template> | ||
<div class="hello"> | ||
<h1>Hello Times: {{ helloTimes }}</h1> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
import Component from '../lib/index' | ||
|
||
@Component | ||
export default class Hello extends Vue { | ||
helloTimes: number = 0 | ||
sayHello() { | ||
this.helloTimes++; | ||
} | ||
} | ||
</script> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example in this readme is not written in typescript. So we should not include types.