Skip to content

Commit e602b1d

Browse files
Update provide-inject.md (vuejs#2317)
1 parent 3f4e35c commit e602b1d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/guide/components/provide-inject.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,11 @@ const value = inject('message', 'default value')
208208
In some cases, the default value may need to be created by calling a function or instantiating a new class. To avoid unnecessary computation or side effects in case the optional value is not used, we can use a factory function for creating the default value:
209209

210210
```js
211-
const value = inject('key', () => new ExpensiveClass())
211+
const value = inject('key', () => new ExpensiveClass(), true)
212212
```
213213

214+
The third parameter indicates the default value should be treated as a factory function.
215+
214216
</div>
215217

216218
<div class="options-api">

0 commit comments

Comments
 (0)