Skip to content

Commit

Permalink
Note that props can be accessed in template directly (#487)
Browse files Browse the repository at this point in the history
* Note that props can be accessed in template directly

In "Usage with Templates" the doc shows how props of the object returned from `setup` can be used directly in the template, but I didn't find anywhere else in the composition-api doc where it says that props can also be used directly. This seemed like as good a place as any to add that, since that's where I was looking for it first :-).

* Update src/guide/composition-api-setup.md

Co-authored-by: Natalia Tepluhina <[email protected]>
  • Loading branch information
garyo and NataliaTepluhina committed Sep 18, 2020
1 parent 7e55600 commit c05b8e6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/guide/composition-api-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,19 @@ In other words, you **will not have access** to the following component options:

## Usage with Templates

If `setup` returns an object, the properties on the object can be accessed in the component's template:
If `setup` returns an object, the properties on the object can be accessed in the component's template, as well as the properties of the `props` passed into `setup`:

```vue-html
<!-- MyBook.vue -->
<template>
<div>{{ readersNumber }} {{ book.title }}</div>
<div>{{ props.collectionName }}: {{ readersNumber }} {{ book.title }}</div>
</template>
<script>
import { ref, reactive } from 'vue'
export default {
setup() {
setup(props) {
const readersNumber = ref(0)
const book = reactive({ title: 'Vue 3 Guide' })
Expand Down

0 comments on commit c05b8e6

Please sign in to comment.