Skip to content

Commit 3f66e80

Browse files
docs: reword Vue instance/application parameters mentions (#355)
* fix: fixed names for createApp parameters * fix: removed incorrect provide/inject section * fix: replaced an example with symbol * fix: replaced Vue instances in the API * fix: replaced Vue instance with more specific definition
1 parent 18adfb3 commit 3f66e80

31 files changed

+132
-168
lines changed

src/api/application-api.md

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Apart from `el`, you should treat these arguments as read-only and never modify
158158

159159
- **Usage:**
160160

161-
Apply a mixin in the whole application scope, which will affect **every** Vue instance created afterwards in the given app (for example, child components). This can be used by plugin authors to inject custom behavior into components. **Not recommended in application code**.
161+
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**.
162162

163163
- **See also:** [Global Mixin](../guide/mixins.html#global-mixin)
164164

@@ -192,44 +192,6 @@ app.mount('#my-app')
192192
- **See also:**
193193
- [Lifecycle Diagram](../guide/instance.html#lifecycle-diagram)
194194

195-
## provide
196-
197-
- **Type:**
198-
199-
- `Object | () => Object`
200-
201-
- **Details:**
202-
203-
This option is [used together with `inject`](../api/options-composition.html#provide-inject) to allow an ancestor component to serve as a dependency injector for all its descendants, regardless of how deep the component hierarchy is, as long as they are in the same parent chain.
204-
205-
The `provide` option should be an object or a function that returns an object. This object contains the properties that are available for injection into its descendants. You can use ES2015 Symbols as keys in this object, but only in environments that natively support `Symbol` and `Reflect.ownKeys`.
206-
207-
> Note: 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.
208-
209-
- **Example:**
210-
211-
```js
212-
import { createApp } from 'vue'
213-
214-
const app = createApp({
215-
provide: {
216-
user: 'John Doe'
217-
}
218-
})
219-
220-
app.component('user-card', {
221-
inject: ['user'],
222-
template: `
223-
<div>
224-
{{ user }}
225-
</div>
226-
`
227-
})
228-
```
229-
230-
- **See also:**
231-
- [Provide / Inject](../guide/component-provide-inject.md)
232-
233195
## unmount
234196

235197
- **Arguments:**

src/api/application-config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ app.config.errorHandler = (err, vm, info) => {
3838
}
3939
```
4040

41-
Assign a handler for uncaught errors during component render function and watchers. The handler gets called with the error and the Vue instance.
41+
Assign a handler for uncaught errors during component render function and watchers. The handler gets called with the error and the application instance.
4242

4343
> Error tracking services [Sentry](https://sentry.io/for/vue/) and [Bugsnag](https://docs.bugsnag.com/platforms/browsers/vue/) provide official integrations using this option.
4444
@@ -134,7 +134,7 @@ app.mixin({
134134

135135
Define merging strategies for custom options.
136136

137-
The merge strategy receives the value of that option defined on the parent and child instances as the first and second arguments, respectively. The context Vue instance is passed as the third argument.
137+
The merge strategy receives the value of that option defined on the parent and child instances as the first and second arguments, respectively. The context application instance is passed as the third argument.
138138

139139
- **See also:** [Custom Option Merging Strategies](../guide/mixins.html#custom-option-merge-strategies)
140140

src/api/directives.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@
409409

410410
- **Usage:**
411411

412-
This directive will remain on the element until the associated Vue instance finishes compilation. Combined with CSS rules such as `[v-cloak] { display: none }`, this directive can be used to hide un-compiled mustache bindings until the Vue instance is ready.
412+
This directive will remain on the element until the associated component instance finishes compilation. Combined with CSS rules such as `[v-cloak] { display: none }`, this directive can be used to hide un-compiled mustache bindings until the component instance is ready.
413413

414414
- **Example:**
415415

src/api/instance-methods.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Instance Methods
22

3-
## $watch
3+
## \$watch
44

55
- **Arguments:**
66

@@ -14,7 +14,7 @@
1414

1515
- **Usage:**
1616

17-
Watch a reactive property or a computed function on the Vue instance for changes. The callback gets called with the new value and the old value for the given property. We can only pass top-level `data`, `prop`, or `computed` property name as a string. For more complex expressions or nested properties, use a function instead.
17+
Watch a reactive property or a computed function on the component instance for changes. The callback gets called with the new value and the old value for the given property. We can only pass top-level `data`, `prop`, or `computed` property name as a string. For more complex expressions or nested properties, use a function instead.
1818

1919
- **Example:**
2020

@@ -172,7 +172,7 @@
172172

173173
- **See also:** [Watchers](../guide/computed.html#watchers)
174174

175-
## $emit
175+
## \$emit
176176

177177
- **Arguments:**
178178

@@ -249,13 +249,13 @@
249249
- [`emits` option](./options-data.html#emits)
250250
- [Emitting a Value With an Event](../guide/component-basics.html#emitting-a-value-with-an-event)
251251

252-
## $forceUpdate
252+
## \$forceUpdate
253253

254254
- **Usage:**
255255

256-
Force the Vue instance to re-render. Note it does not affect all child components, only the instance itself and child components with inserted slot content.
256+
Force the component instance to re-render. Note it does not affect all child components, only the instance itself and child components with inserted slot content.
257257

258-
## $nextTick
258+
## \$nextTick
259259

260260
- **Arguments:**
261261

src/api/instance-properties.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
- **Details:**
88

9-
The data object that the Vue instance is observing. The Vue instance proxies access to the properties on its data object.
9+
The data object that the component instance is observing. The component instance proxies access to the properties on its data object.
1010

1111
- **See also:** [Options / Data - data](./options-data.html#data-2)
1212

@@ -16,7 +16,7 @@
1616

1717
- **Details:**
1818

19-
An object representing the current props a component has received. The Vue instance proxies access to the properties on its props object.
19+
An object representing the current props a component has received. The component instance proxies access to the properties on its props object.
2020

2121
## $el
2222

@@ -26,7 +26,7 @@
2626

2727
- **Details:**
2828

29-
The root DOM element that the Vue instance is managing.
29+
The root DOM element that the component instance is managing.
3030

3131
## $options
3232

@@ -36,7 +36,7 @@
3636

3737
- **Details:**
3838

39-
The instantiation options used for the current Vue instance. This is useful when you want to include custom properties in the options:
39+
The instantiation options used for the current component instance. This is useful when you want to include custom properties in the options:
4040

4141
```js
4242
const app = Vue.createApp({
@@ -49,7 +49,7 @@
4949

5050
## $parent
5151

52-
- **Type:** `Vue instance`
52+
- **Type:** `Component instance`
5353

5454
- **Read only**
5555

@@ -59,13 +59,13 @@
5959

6060
## $root
6161

62-
- **Type:** `Vue instance`
62+
- **Type:** `Component instance`
6363

6464
- **Read only**
6565

6666
- **Details:**
6767

68-
The root Vue instance of the current component tree. If the current instance has no parents this value will be itself.
68+
The root component instance of the current component tree. If the current instance has no parents this value will be itself.
6969

7070
## $slots
7171

src/api/options-assets.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
- **Details:**
88

9-
A hash of directives to be made available to the Vue instance.
9+
A hash of directives to be made available to the component instance.
1010

1111
- **See also:** [Custom Directives](../guide/custom-directive.html)
1212

@@ -16,6 +16,6 @@
1616

1717
- **Details:**
1818

19-
A hash of components to be made available to the Vue instance.
19+
A hash of components to be made available to the component instance.
2020

2121
- **See also:** [Components](../guide/component-basics.html)

src/api/options-data.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66

77
- **Details:**
88

9-
The function that returns a data object for the Vue instance. In `data`, we don't recommend to observe objects with their own stateful behavior like browser API objects and prototype properties. A good idea would be to have here just a plain object that represents component data.
9+
The function that returns a data object for the component instance. In `data`, we don't recommend to observe objects with their own stateful behavior like browser API objects and prototype properties. A good idea would be to have here just a plain object that represents component data.
1010

1111
Once observed, you can no longer add reactive properties to the root data object. It is therefore recommended to declare all root-level reactive properties upfront, before creating the instance.
1212

13-
After the instance is created, the original data object can be accessed as `vm.$data`. The Vue instance also proxies all the properties found on the data object, so `vm.a` will be equivalent to `vm.$data.a`.
13+
After the instance is created, the original data object can be accessed as `vm.$data`. The component instance also proxies all the properties found on the data object, so `vm.a` will be equivalent to `vm.$data.a`.
1414

15-
Properties that start with `_` or `$` will **not** be proxied on the Vue instance because they may conflict with Vue's internal properties and API methods. You will have to access them as `vm.$data._property`.
15+
Properties that start with `_` or `$` will **not** be proxied on the component instance because they may conflict with Vue's internal properties and API methods. You will have to access them as `vm.$data._property`.
1616

1717
- **Example:**
1818

1919
```js
2020
// direct instance creation
2121
const data = { a: 1 }
2222

23-
// The object is added to a Vue instance
23+
// The object is added to a component instance
2424
const vm = Vue.createApp({
2525
data() {
2626
return data
@@ -92,7 +92,7 @@
9292

9393
- **Details:**
9494

95-
Computed properties to be mixed into the Vue instance. All getters and setters have their `this` context automatically bound to the Vue instance.
95+
Computed properties to be mixed into the Vcomponent instance. All getters and setters have their `this` context automatically bound to the component instance.
9696

9797
Note that if you use an arrow function with a computed property, `this` won't be the component's instance, but you can still access the instance as the function's first argument:
9898

@@ -143,10 +143,10 @@
143143

144144
- **Details:**
145145

146-
Methods to be mixed into the Vue instance. You can access these methods directly on the VM instance, or use them in directive expressions. All methods will have their `this` context automatically bound to the Vue instance.
146+
Methods to be mixed into the component instance. You can access these methods directly on the VM instance, or use them in directive expressions. All methods will have their `this` context automatically bound to the component instance.
147147

148148
:::tip Note
149-
Note that **you should not use an arrow function to define a method** (e.g. `plus: () => this.a++`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.a` will be undefined.
149+
Note that **you should not use an arrow function to define a method** (e.g. `plus: () => this.a++`). The reason is arrow functions bind the parent context, so `this` will not be the component instance as you expect and `this.a` will be undefined.
150150
:::
151151

152152
- **Example:**
@@ -177,7 +177,7 @@
177177

178178
- **Details:**
179179

180-
An object where keys are expressions to watch and values are the corresponding callbacks. The value can also be a string of a method name, or an Object that contains additional options. The Vue instance will call `$watch()` for each entry in the object at instantiation.
180+
An object where keys are expressions to watch and values are the corresponding callbacks. The value can also be a string of a method name, or an Object that contains additional options. The component instance will call `$watch()` for each entry in the object at instantiation.
181181

182182
- **Example:**
183183

@@ -244,7 +244,7 @@
244244
```
245245

246246
::: tip Note
247-
Note that _you should not use an arrow function to define a watcher_ (e.g. `searchQuery: newValue => this.updateAutocomplete(newValue)`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.updateAutocomplete` will be undefined.
247+
Note that _you should not use an arrow function to define a watcher_ (e.g. `searchQuery: newValue => this.updateAutocomplete(newValue)`). The reason is arrow functions bind the parent context, so `this` will not be the component instance as you expect and `this.updateAutocomplete` will be undefined.
248248
:::
249249

250250
- **See also:** [Watchers](../guide/computed.html#watchers)
@@ -290,10 +290,9 @@
290290
}
291291
})
292292
```
293-
293+
294294
::: tip Note
295295
Events listed in the `emits` option **will not** be inherited by the root element of the component and also will be excluded from the `$attrs` property.
296296
:::
297-
298297

299-
- **See also:** [Attribute Inheritance](../guide/component-props.html#non-prop-attributes)
298+
* **See also:** [Attribute Inheritance](../guide/component-props.html#non-prop-attributes)

src/api/options-dom.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
- **Details:**
88

9-
A string template to be used as the markup for the Vue instance. The template will **replace** the mounted element. Any existing markup inside the mounted element will be ignored, unless content distribution slots are present in the template.
9+
A string template to be used as the markup for the component instance. The template will **replace** the mounted element. Any existing markup inside the mounted element will be ignored, unless content distribution slots are present in the template.
1010

1111
If the string starts with `#` it will be used as a `querySelector` and use the selected element's innerHTML as the template string. This allows the use of the common `<script type="x-template">` trick to include templates.
1212

src/api/options-lifecycle-hooks.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Lifecycle hooks
22

33
:::tip Note
4-
All lifecycle hooks automatically have their `this` context bound to the instance, so that you can access data, computed properties, and methods. This means **you should not use an arrow function to define a lifecycle method** (e.g. `created: () => this.fetchTodos()`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.fetchTodos` will be undefined.
4+
All lifecycle hooks automatically have their `this` context bound to the instance, so that you can access data, computed properties, and methods. This means **you should not use an arrow function to define a lifecycle method** (e.g. `created: () => this.fetchTodos()`). The reason is arrow functions bind the parent context, so `this` will not be the component instance as you expect and `this.fetchTodos` will be undefined.
55
:::
66

77
## beforeCreate
@@ -128,7 +128,7 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
128128

129129
- **Details:**
130130

131-
Called right before a Vue instance is unmounted. At this stage the instance is still fully functional.
131+
Called right before a component instance is unmounted. At this stage the instance is still fully functional.
132132

133133
**This hook is not called during server-side rendering.**
134134

@@ -140,7 +140,7 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
140140

141141
- **Details:**
142142

143-
Called after a Vue instance has been unmounted. When this hook is called, all directives of the Vue instance have been unbound, all event listeners have been removed, and all child Vue instances have also been unmounted.
143+
Called after a component instance has been unmounted. When this hook is called, all directives of the component instance have been unbound, all event listeners have been removed, and all child component instance have also been unmounted.
144144

145145
**This hook is not called during server-side rendering.**
146146

src/guide/change-detection.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ vm.items.splice(newLength)
8484

8585
## Declaring Reactive Properties
8686

87-
Since Vue doesn't allow dynamically adding root-level reactive properties, you have to initialize Vue instances by declaring all root-level reactive data properties upfront, even with an empty value:
87+
Since Vue doesn't allow dynamically adding root-level reactive properties, you have to initialize component instances by declaring all root-level reactive data properties upfront, even with an empty value:
8888

8989
```js
9090
var vm = new Vue({
@@ -100,7 +100,7 @@ vm.message = 'Hello!'
100100

101101
If you don't declare `message` in the data option, Vue will warn you that the render function is trying to access a property that doesn't exist.
102102

103-
There are technical reasons behind this restriction - it eliminates a class of edge cases in the dependency tracking system, and also makes Vue instances play nicer with type checking systems. But there is also an important consideration in terms of code maintainability: the `data` object is like the schema for your component's state. Declaring all reactive properties upfront makes the component code easier to understand when revisited later or read by another developer.
103+
There are technical reasons behind this restriction - it eliminates a class of edge cases in the dependency tracking system, and also makes component instances play nicer with type checking systems. But there is also an important consideration in terms of code maintainability: the `data` object is like the schema for your component's state. Declaring all reactive properties upfront makes the component code easier to understand when revisited later or read by another developer.
104104

105105
## Async Update Queue
106106

@@ -126,7 +126,7 @@ Vue.nextTick(function() {
126126
})
127127
```
128128

129-
There is also the `vm.$nextTick()` instance method, which is especially handy inside components, because it doesn't need global `Vue` and its callback's `this` context will be automatically bound to the current Vue instance:
129+
There is also the `vm.$nextTick()` instance method, which is especially handy inside components, because it doesn't need global `Vue` and its callback's `this` context will be automatically bound to the current component instance:
130130

131131
```js
132132
Vue.component('example', {

src/guide/class-and-style.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ When you use the `class` attribute on a custom component with a single root elem
128128
For example, if you declare this component:
129129

130130
```js
131-
const app = Vue.createApp()
131+
const app = Vue.createApp({})
132132

133133
app.component('my-component', {
134134
template: `<p class="foo bar">Hi!</p>`
@@ -170,7 +170,7 @@ If your component has multiple root elements, you would need to define which com
170170
```
171171

172172
```js
173-
const app = Vue.createApp()
173+
const app = Vue.createApp({})
174174

175175
app.component('my-component', {
176176
template: `

0 commit comments

Comments
 (0)