Skip to content

Commit 7c1c5a6

Browse files
committed
Migration Guide > Props Default Function this Access の翻訳元ファイル追加 ( #122 )
1 parent 41a46fb commit 7c1c5a6

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: Props Default Function this Access
3+
badges:
4+
- breaking
5+
---
6+
7+
# Props Default Function `this` Access <MigrationBadges :badges="$frontmatter.badges" />
8+
9+
Props default value factory functions no longer have access to `this`.
10+
11+
Instead:
12+
13+
- Raw props received by the component are passed to the default function as argument;
14+
15+
- The [inject](../composition-api-provide-inject.md) API can be used inside default functions.
16+
17+
```js
18+
import { inject } from 'vue'
19+
20+
export default {
21+
props: {
22+
theme: {
23+
default (props) {
24+
// `props` is the raw values passed to the component,
25+
// before any type / default coercions
26+
// can also use `inject` to access injected properties
27+
return inject('theme', 'default-theme')
28+
}
29+
}
30+
}
31+
}
32+
```

0 commit comments

Comments
 (0)