There is a lot of documentation how to interact with Vue.js using the JavaScript language and just a little about TypeScript. The question is how do you define computed props in a vue component if it is written in TypeScript?
According the official example, computed is an object with functions which will be cached based on their dependent props.
Here is an example I made:
import Vue from 'vue';
import { Component } from "vue-property-decorator";
@Component({})
export default class ComputedDemo extends Vue {
private firstName: string = 'John';
private lastName: string = 'Doe';
private computed: object = {
fullName(): string {
return `${this.firstName} ${this.lastName}`;
},
}
}
And html:
<div>
<h1>Computed props ts demo</h1>
<ul>
<li>First name: {{firstName}}</li>
<li>Last name: {{lastName}}</li>
<li>Together: {{fullName}}</li>
</ul>
</div>
The third list item outputs nothing. Can anybody tell me how to define computed in this case, please?