Slide 37
Slide 37 text
Class-style api
Class-style api
@Component
export default class Count extends Vue {
@Prop() msg!: string;
private count: number = 0;
private add(): void {
this.count += 1;
}
private minus(): void {
this.count -= 1;
}
get isEven(): boolean {
return this.count % 2 === 0;
}
}
export default Vue.extend({
name: "Count",
props: {
msg: {
type: String,
required: true,
},
},
data() {
return {
count: 0,
};
},
computed: {
isEven(): boolean {
return this.count % 2 === 0;
},
},
methods: {
add(): void {
this.count += 1;
},
minus(): void {
this.count -= 1;
},
},
});
Class-style api
Ұൠతͳॻ͖ํ