Skip to content

Commit

Permalink
chore(readme): add docs for Reactive data
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Jan 19, 2021
1 parent 44c9931 commit 95a36ed
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,36 @@ export default defineComponent({
</script>
```

### Reactive data

In many cases you want to make head tags dynamic, e.g. update document title when clicked a button:

```vue
<template>
<button @click="count++">Click</button>
</template>
<script>
import { defineComponent, ref, computed } from 'vue'
export default defineComponent({
setup() {
const count = ref(0)
useHead({
title: computed(() => `Clicked ${count.value} times`),
})
return {
count,
}
},
})
</script>
```

`meta`, `base` and other properties can also be a `RefObject` like the `title` here, check out [API](#api) for more.

### Server-side rendering

```ts
Expand Down

0 comments on commit 95a36ed

Please sign in to comment.