Skip to content

Commit c05b8e6

Browse files
Note that props can be accessed in template directly (#487)
* 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 <tarya.se@gmail.com>
1 parent 7e55600 commit c05b8e6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/guide/composition-api-setup.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,19 @@ In other words, you **will not have access** to the following component options:
9999

100100
## Usage with Templates
101101

102-
If `setup` returns an object, the properties on the object can be accessed in the component's template:
102+
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`:
103103

104104
```vue-html
105105
<!-- MyBook.vue -->
106106
<template>
107-
<div>{{ readersNumber }} {{ book.title }}</div>
107+
<div>{{ props.collectionName }}: {{ readersNumber }} {{ book.title }}</div>
108108
</template>
109109
110110
<script>
111111
import { ref, reactive } from 'vue'
112112
113113
export default {
114-
setup() {
114+
setup(props) {
115115
const readersNumber = ref(0)
116116
const book = reactive({ title: 'Vue 3 Guide' })
117117

0 commit comments

Comments
 (0)