Skip to content

Commit 7985ec1

Browse files
skirtles-codebencodezen
authored andcommitted
docs: update the API entries for mixins and extends (#1146)
* docs: update the API entries for mixins and extends * Update src/api/options-composition.md Co-authored-by: Ben Hong <ben@bencodezen.io>
1 parent 71561cd commit 7985ec1

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/api/options-composition.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010

1111
ミックスインフックは提供された順番に呼び出され、コンポーネント自身のフックよりも前に呼び出されます。
1212

13+
:::info
14+
In Vue 2, mixins were the primary mechanism for creating reusable chunks of component logic. While mixins continue to be supported in Vue 3, the [Composition API](/guide/composition-api-introduction.html) is now the preferred approach for code reuse between components.
15+
:::
16+
1317
- **例:**
1418

1519
```js
1620
const mixin = {
17-
created: function() {
21+
created() {
1822
console.log(1)
1923
}
2024
}
@@ -34,20 +38,23 @@
3438

3539
## extends
3640

37-
- **型:** `Object | Function`
41+
- **型:** `Object`
3842

3943
- **詳細:**
4044

41-
別のコンポーネントを宣言的に拡張できます(純粋なオプションオブジェクトまたはコンストラクタのどちらでも)。これは主に単一ファイルコンポーネント間の拡張を簡単にすることを目的としています。
45+
Allows one component to extend another, inheriting its component options.
46+
47+
From an implementation perspective, `extends` is almost identical to `mixins`. The component specified by `extends` will be treated as though it were the first mixin.
48+
49+
However, `extends` and `mixins` express different intents. The `mixins` option is primarily used to compose chunks of functionality, whereas `extends` is primarily concerned with inheritance.
4250

43-
これは `mixins` に似ています。
51+
As with `mixins`, any options will be merged using the relevant merge strategy.
4452

4553
- **例:**
4654

4755
```js
4856
const CompA = { ... }
4957

50-
// CompA を `Vue.extend` の呼び出しなしで拡張します
5158
const CompB = {
5259
extends: CompA,
5360
...

0 commit comments

Comments
 (0)