Skip to content

Commit 42bb2a2

Browse files
The description of this in setup is inconsistent with the source code (#1063)
* The description of `this` in setup is inconsistent with the source code * More accurate description of `this` in the setup function Co-authored-by: skirtle <[email protected]> * fix:Removed some formatted commas Co-authored-by: coderwhy <[email protected]> Co-authored-by: skirtle <[email protected]>
1 parent de8b55a commit 42bb2a2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/guide/composition-api-introduction.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Now that we know the **why** we can get to the **how**. To start working with th
7676
The new `setup` component option is executed **before** the component is created, once the `props` are resolved, and serves as the entry point for composition API's.
7777

7878
::: warning
79-
Because the component instance is not yet created when `setup` is executed, there is no `this` inside a `setup` option. This means, with the exception of `props`, you won't be able to access any properties declared in the component – **local state**, **computed properties** or **methods**.
79+
You should avoid using `this` inside `setup` as it won't refer to the component instance. `setup` is called before `data` properties, `computed` properties or `methods` are resolved, so they won't be available within `setup`.
8080
:::
8181

8282
The `setup` option should be a function that accepts `props` and `context` which we will talk about [later](composition-api-setup.html#arguments). Additionally, everything that we return from `setup` will be exposed to the rest of our component (computed properties, methods, lifecycle hooks and so on) as well as to the component's template.

0 commit comments

Comments
 (0)