@@ -122,28 +122,20 @@ app.use(VueRouter)
122
122
123
123
## Mounting App Instance
124
124
125
- After being initialized with ` createApp() ` , the app instance ` app ` can be used to mount a Vue root instance with ` app.mount(VueInstance, domTarget) ` :
125
+ After being initialized with ` createApp(VueInstance ) ` , the app instance ` app ` can be used to mount a Vue root instance with ` app.mount(domTarget) ` :
126
126
127
127
``` js
128
128
import { createApp } from ' vue'
129
129
import MyApp from ' ./MyApp.vue'
130
130
131
- const app = createApp ()
132
- app .mount (MyApp, ‘#app’)
133
- ```
134
-
135
- The ` mount ` method can also accept props to be passed to the root component via a third argument:
136
-
137
- ``` js
138
- app .mount (MyApp, ' #app' , {
139
- // props to be passed to root component
140
- })
131
+ const app = createApp (MyApp)
132
+ app .mount (' #app' )
141
133
```
142
134
143
135
With all these changes, the component and directive we have at the beginning of the guide will be rewritten into something like this:
144
136
145
137
``` js
146
- const app = createApp ()
138
+ const app = createApp (MyApp )
147
139
148
140
app .component (' button-counter' , {
149
141
data : () => ({
@@ -159,7 +151,7 @@ app.directive('focus', {
159
151
// now every Vue instance mounted with app.mount(), along with its
160
152
// component tree, will have the same “button-counter” component
161
153
// and “focus” directive without polluting the global environment
162
- app .mount (MyApp, ' #app' )
154
+ app .mount (' #app' )
163
155
```
164
156
165
157
## Provide / Inject
@@ -192,15 +184,15 @@ import { createApp } from 'vue'
192
184
import Foo from ' ./Foo.vue'
193
185
import Bar from ' ./Bar.vue'
194
186
195
- const createMyApp = () => {
196
- const app = createApp ({} )
187
+ const createMyApp = (VueInstance ) => {
188
+ const app = createApp (VueInstance )
197
189
app .directive (' focus' /* ... */ )
198
190
199
191
return app
200
192
}
201
193
202
- createMyApp ().mount (Foo, ' #foo' )
203
- createMyApp ().mount (Bar, ' #bar' )
194
+ createMyApp (Foo ).mount (' #foo' )
195
+ createMyApp (Bar ).mount (' #bar' )
204
196
```
205
197
206
198
Now the ` focus ` directive will be available in both Foo and Bar instances and their descendants.
0 commit comments