Computed Property
Computed Property#
Let's keep building on top of the todo list from the last step. Here, we've already added a toggle functionality to each todo. This is done by adding a done property to each todo object, and using v-model to bind it to a checkbox:
```vue-html{2}
The next improvement we can add is to be able to hide already completed todos. We already have a button that toggles the `hideCompleted` state. But how do we render different list items based on that state?
<div class="options-api">
Introducing <a target="_blank" href="/guide/essentials/computed.html">computed property</a>. We can declare a property that is reactively computed from other properties using the `computed` option:
<div class="sfc">
```js
export default {
// ...
computed: {
filteredTodos() {
// return filtered todos based on `this.hideCompleted`
}
}
}
createApp({
// ...
computed: {
filteredTodos() {
// return filtered todos based on `this.hideCompleted`
}
}
})