You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> This guide assumes that you have already read the [Composition API Introduction](composition-api-introduction.html) and [Reactivity Fundamentals](reactivity-fundamentals.html). Read that first if you are new to Composition API.
5
+
> このガイドは[コンポジション API の導入](composition-api-introduction.html)と[リアクティブの基礎](reactivity-fundamentals.html)を既に読んでいることを想定しています。 コンポジション API に初めて触れる方は、まずそちらを読んでみてください。
6
6
7
-
## Arguments
7
+
## 引数
8
8
9
-
When using the `setup`function, it will take two arguments:
9
+
`setup`関数を使う時、2 つの引数を取ります:
10
10
11
11
1.`props`
12
12
2.`context`
13
13
14
-
Let's dive deeper into how each argument can be used.
14
+
それぞれの引数がどのように使われるのか、深く掘り下げてみましょう。
15
15
16
-
### Props
16
+
### プロパティ
17
17
18
-
The first argument in the `setup`function is the `props`argument. Just as you would expect in a standard component, `props` inside of a `setup` function are reactive and will be updated when new props are passed in.
If you need to destructure your props, you can do this safely by utilizing the [toRefs](reactivity-fundamentals.html#destructuring-reactive-state)inside of the `setup` function.
The second argument passed to the `setup`function is the `context`. The `context`is a normal JavaScript object that exposes three component properties:
`attrs`and`slots`are stateful objects that are always updated when the component itself is updated. This means you should avoid destructuring them and always reference properties as `attrs.x`or`slots.x`. Also note that unlike `props`,`attrs`and`slots`are **not** reactive. If you intend to apply side effects based on `attrs`or`slots`changes, you should do so inside an `onUpdated`lifecycle hook.
@@ -125,11 +125,11 @@ If `setup` returns an object, the properties on the object can be accessed in th
125
125
</script>
126
126
```
127
127
128
-
Note that[refs](../api/refs-api.html#ref)returned from `setup` are [automatically unwrapped](../api/refs-api.html#access-in-templates) when accessed in the template so you shouldn't use `.value`in templates.
**Inside `setup()`, `this`won't be a reference to the current active instance**Since `setup()`is called before other component options are resolved, `this` inside `setup()`will behave quite differently from `this` in other options. This might cause confusions when using `setup()`along other Options API.
151
+
**`setup()` 内では、`this`は現在のアクティブなインスタンスへの参照にはなりません。**`setup()`は他のコンポーネントオプションが解決される前に呼び出されるので、`setup()`内の`this` は他のオプション内の `this`とは全く異なる振る舞いをします。 これは、`setup()`を他のオプション API と一緒に使った場合に混乱を引き起こす可能性があります。
0 commit comments