Skip to content

Commit 8d4d271

Browse files
docs: add return values for application API methods (vuejs#427)
1 parent 6a8d555 commit 8d4d271

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/api/application-api.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ In addition, since the `createApp` method returns the application instance itsel
1919
- `{string} name`
2020
- `{Function | Object} [definition]`
2121

22+
- **Returns:**
23+
24+
- The application instance if a `definition` argument was passed
25+
- The component definition if a `definition` argument was not passed
26+
2227
- **Usage:**
2328

2429
Register or retrieve a global component. Registration also automatically sets the component's `name` with the given `name` parameter.
@@ -35,8 +40,8 @@ app.component('my-component', {
3540
/* ... */
3641
})
3742

38-
// retrieve a registered component (always return constructor)
39-
const MyComponent = app.component('my-component', {})
43+
// retrieve a registered component
44+
const MyComponent = app.component('my-component')
4045
```
4146

4247
- **See also:** [Components](../guide/component-basics.html)
@@ -65,6 +70,11 @@ app.config = {...}
6570
- `{string} name`
6671
- `{Function | Object} [definition]`
6772

73+
- **Returns:**
74+
75+
- The application instance if a `definition` argument was passed
76+
- The directive definition if a `definition` argument was not passed
77+
6878
- **Usage:**
6979

7080
Register or retrieve a global directive.
@@ -156,6 +166,10 @@ Apart from `el`, you should treat these arguments as read-only and never modify
156166

157167
- `{Object} mixin`
158168

169+
- **Returns:**
170+
171+
- The application instance
172+
159173
- **Usage:**
160174

161175
Apply a mixin in the whole application scope. Once registered they can be used in the template of any component within the current application. This can be used by plugin authors to inject custom behavior into components. **Not recommended in application code**.
@@ -169,6 +183,10 @@ Apart from `el`, you should treat these arguments as read-only and never modify
169183
- `{Element | string} rootContainer`
170184
- `{boolean} isHydrate`
171185

186+
- **Returns:**
187+
188+
- The root component instance
189+
172190
- **Usage:**
173191

174192
Mounts a root component of the application instance on the provided DOM element.
@@ -199,6 +217,10 @@ app.mount('#my-app')
199217
- `{string | Symbol} key`
200218
- `value`
201219

220+
- **Returns:**
221+
222+
- The application instance
223+
202224
- **Usage:**
203225

204226
Sets a value that can be injected into all components within the application. Components should use `inject` to receive the provided values.
@@ -209,8 +231,6 @@ app.mount('#my-app')
209231

210232
Providing values via the application is especially useful when writing plugins, as plugins typically wouldn't be able to provide values using components. It is an alternative to using [globalProperties](application-config.html#globalproperties).
211233

212-
Returns the application instance, allowing calls to be chained.
213-
214234
:::tip Note
215235
The `provide` and `inject` bindings are NOT reactive. This is intentional. However, if you pass down an observed object, properties on that object do remain reactive.
216236
:::
@@ -272,6 +292,10 @@ setTimeout(() => app.unmount('#my-app'), 5000)
272292

273293
- `{Object | Function} plugin`
274294

295+
- **Returns:**
296+
297+
- The application instance
298+
275299
- **Usage:**
276300

277301
Install a Vue.js plugin. If the plugin is an Object, it must expose an `install` method. If it is a function itself, it will be treated as the install method. The install method will be called with Vue as the argument.

0 commit comments

Comments
 (0)