You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/api/application-api.md
+8-6Lines changed: 8 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ In addition, since the `createApp` method returns the application instance itsel
22
22
-**Returns:**
23
23
24
24
- The application instance if a `definition` argument was passed
25
-
- The component definition if a `definition` argument was not passed
25
+
- The component definition if a `definition` argument was not passed
26
26
27
27
-**Usage:**
28
28
@@ -73,7 +73,7 @@ app.config = {...}
73
73
-**Returns:**
74
74
75
75
- The application instance if a `definition` argument was passed
76
-
- The directive definition if a `definition` argument was not passed
76
+
- The directive definition if a `definition` argument was not passed
77
77
78
78
-**Usage:**
79
79
@@ -88,6 +88,8 @@ const app = createApp({})
88
88
// register
89
89
app.directive('my-directive', {
90
90
// Directive has a set of lifecycle hooks:
91
+
// called before bound element's attributes or event listeners are applied
92
+
created() {},
91
93
// called before bound element's parent component is mounted
92
94
beforeMount() {},
93
95
// called when bound element's parent component is mounted
@@ -168,7 +170,7 @@ Apart from `el`, you should treat these arguments as read-only and never modify
168
170
169
171
-**Returns:**
170
172
171
-
- The application instance
173
+
- The application instance
172
174
173
175
-**Usage:**
174
176
@@ -224,10 +226,10 @@ app.mount('#my-app')
224
226
-**Usage:**
225
227
226
228
Sets a value that can be injected into all components within the application. Components should use `inject` to receive the provided values.
227
-
229
+
228
230
From a `provide`/`inject` perspective, the application can be thought of as the root-level ancestor, with the root component as its only child.
229
231
230
-
This method should not be confused with the [provide component option](options-composition.html#provide-inject) or the [provide function](composition-api.html#provide-inject) in the composition API. While those are also part of the same `provide`/`inject` mechanism, they are used to configure values provided by a component rather than an application.
232
+
This method should not be confused with the [provide component option](options-composition.html#provide-inject) or the [provide function](composition-api.html#provide-inject) in the composition API. While those are also part of the same `provide`/`inject` mechanism, they are used to configure values provided by a component rather than an application.
231
233
232
234
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).
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.
303
-
305
+
304
306
The install method will be called with the application as its first argument. Any `options` passed to `use` will be passed on in subsequent arguments.
305
307
306
308
When this method is called on the same plugin multiple times, the plugin will be installed only once.
Copy file name to clipboardExpand all lines: src/guide/custom-directive.md
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,9 @@ Then in a template, you can use the new `v-focus` attribute on any element, like
45
45
46
46
A directive definition object can provide several hook functions (all optional):
47
47
48
-
-`beforeMount`: called when the directive is first bound to the element and before parent component is mounted. This is where you can do one-time setup work.
48
+
-`created`: called before the bound element's attributes or event listeners are applied. This is useful in cases where the directive needs to attach event listeners that must be called before normal `v-on` event listeners.
49
+
50
+
-`beforeMount`: called when the directive is first bound to the element and before parent component is mounted.
49
51
50
52
-`mounted`: called when the bound element's parent component is mounted.
Copy file name to clipboardExpand all lines: src/guide/migration/custom-directives.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,7 @@ Here, in the initial setup for this element, the directive binds a style by pass
39
39
40
40
In Vue 3, however, we’ve created a more cohesive API for custom directives. As you can see, they differ greatly from our component lifecycle methods even though we’re hooking into similar events. We’ve now unified them like so:
41
41
42
+
-**created** - new! This is called before the element's attributes or event listeners are applied.
42
43
- bind → **beforeMount**
43
44
- inserted → **mounted**
44
45
-**beforeUpdate**: new! This is called before the element itself is updated, much like the component lifecycle hooks.
0 commit comments