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
When using the compiler-included build and mounting a root component with no template of its own, Vue will attempt to use the mount target element's content as template. Note the differences between the 3.x behavior and 2.x:
139
+
140
+
- In 2.x, the root instance uses target element's `outerHTML` as template and replaces target element itself.
141
+
142
+
- In 3.x, the root instance uses target element's `innerHTML` as template and only replaces target element's children.
143
+
144
+
In most cases this should have no effect on how your app behaves, with the only side effect being that if the target element contains multiple children, the root instance will be mounted as a fragment and its `this.$el` will be pointing to the starting anchor node of the fragment (a DOM Comment node).
145
+
146
+
In Vue 3, due to the availability of Fragments, it is recommended to use template refs for direct access to DOM nodes instead of relying on `this.$el`.
147
+
132
148
## Provide / Inject
133
149
134
150
An app instance can also provide dependencies that can be injected by any component inside the app:
@@ -177,6 +193,21 @@ app.config.isCustomElement = tag => tag.startsWith('ion-')
177
193
178
194
- This will be a new top-level option in the Vue CLI config.
179
195
196
+
## Attaching Globally Shared Instance Properties
197
+
198
+
In 2.x, it was possible to inject globally shared instance properties by simply attaching them to `Vue.prototype`.
199
+
200
+
In Vue 3, since the global `Vue` is no longer a constructor, this is no longer supported. Instead, shared instance properties should be attached to an app instance's `config.globalProperties` instead:
0 commit comments