Skip to content

Commit 0cd792a

Browse files
authored
Merge pull request #162 from daisuke85a/migration-guide-props-default-this
Migration Guide > Props Default Function `this` Access の翻訳元ファイル追加と翻訳
2 parents 007d213 + b79990c commit 0cd792a

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/.vuepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ const sidebar = {
125125
'migration/global-api-treeshaking',
126126
'migration/inline-template-attribute',
127127
'migration/keycode-modifiers',
128+
'migration/props-default-this',
128129
'migration/render-function-api',
129130
'migration/slots-unification',
130131
'migration/transition',
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: プロパティのデフォルト値ファクトリ関数の `this` アクセス
3+
badges:
4+
- breaking
5+
---
6+
7+
# プロパティのデフォルト値ファクトリ関数の `this` アクセス <MigrationBadges :badges="$frontmatter.badges" />
8+
9+
プロパティのデフォルト値ファクトリ関数が `this` にアクセスできなくなりました。
10+
11+
代わりの方法は以下です。
12+
13+
- コンポーネントが受け取った生のプロパティは、引数としてデフォルト関数に渡されます。
14+
15+
- [inject](../composition-api-provide-inject.md) API がデフォルト関数の内部で使用できます。
16+
17+
```js
18+
import { inject } from 'vue'
19+
20+
export default {
21+
props: {
22+
theme: {
23+
default (props) {
24+
// `props` 引数はコンポーネントに渡される生の値で、
25+
// 型やデフォルトの強制より前のものです。
26+
// また、`inject` を使用して注入されたプロパティにアクセスすることもできます。
27+
return inject('theme', 'default-theme')
28+
}
29+
}
30+
}
31+
}
32+
```

0 commit comments

Comments
 (0)