24 lines
544 B
TypeScript
24 lines
544 B
TypeScript
import { Component, Vue, Prop } from 'vue-property-decorator';
|
||
|
||
@Component
|
||
export default class HelloWorld extends Vue {
|
||
|
||
@Prop({ default: 'default value' }) public readonly msg!: string;
|
||
|
||
private mounted() {
|
||
// console.log(...this.$slots.default)
|
||
}
|
||
private showAlert() {
|
||
alert("showAlert")
|
||
}
|
||
|
||
private render() {
|
||
return (
|
||
<div class="hello">
|
||
<h1>{this.msg}</h1>
|
||
{this.$slots.default}
|
||
<h2 onclick={()=>this.showAlert()}>HelloWorld组件点击事件:{this.msg}</h2>
|
||
</div>
|
||
)
|
||
}
|
||
} |