Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upGlobal mounting/configuration API change #29
Conversation
This comment has been minimized.
This comment has been minimized.
Kocal
commented
Apr 9, 2019
Nice, mutating Vue app instances instead of global Vue instance is SO much better! |
This comment has been minimized.
This comment has been minimized.
jacekkarczmarczyk
commented
May 30, 2019
Is there a reason for initializing import { createApp } from 'vue'
import App1 from './App1.vue';
import App2 from './App2.vue';
const app = createApp();
app.use(...);
...
app.mount('#app-1', App1);
app.mount('#app-2', App2); That would allow to reuse the app object in some cases (but still you can create separate apps if you don't want to share anything) |
This comment has been minimized.
This comment has been minimized.
ycmjason
commented
May 30, 2019
•
But conceptually shouldn't
This seems rather counter intuitive. Perhaps it's the naming. If you wish to use the same config in both apps, I reckon you can do something like: import { createApp } from 'vue'
import App1 from './App1.vue';
import App2 from './App2.vue';
const createMyApp = (component) => {
const app = createApp(component);
app.config.ignoredElements = [/^app-/]
app.use(/* ... */)
app.mixin(/* ... */)
app.component(/* ... */)
app.directive(/* ... */)
return app
};
createMyApp(App1).mount('#app-1');
createMyApp(App2).mount('#app-2');
In this case you gain more flexibility too over what config to use on each app. |
This comment has been minimized.
This comment has been minimized.
MichMich
commented
May 30, 2019
Are the app methods chainable? It would be great if we could write: import { createApp } from 'vue'
import App from './App.vue'
const app = createApp(App)
app.config.ignoredElements = [/^app-/]
app.use(/* ... */)
.mixin(/* ... */)
.component(/* ... */)
.directive(/* ... */)
.mount('#app') And since I don't use the igoneElements feature, this could be simplified to: import { createApp } from 'vue'
import App from './App.vue'
createApp(App)
.use(/* ... */)
.mixin(/* ... */)
.component(/* ... */)
.directive(/* ... */)
.mount('#app') |
This comment has been minimized.
This comment has been minimized.
jacekkarczmarczyk
commented
May 30, 2019
•
@ycmjason I'm not sure whether an
I don't agree with this, because my propsal allows you to use a separate apps/configs or shared one depending on your needs, your solution still doesn't allow to share the config. Another question (not related to this topic) is where do we put Vuex or Router here? |
This comment has been minimized.
This comment has been minimized.
MichMich
commented
May 30, 2019
For me it would make more sense to use: createApp({ store, router })
.use(/* ... */)
.mixin(/* ... */)
.component(/* ... */)
.directive(/* ... */)
.mount('#app', App) |
This comment has been minimized.
This comment has been minimized.
This RFC is now in final comments stage. An RFC in final comments stage means that:
|
cuongdevjs left a comment •
Cool |
This comment has been minimized.
This comment has been minimized.
Was thinking this will allow the devtools to inject a proper Vue app into the page instead of hand-made DOM manipulations (for the Component overlay for example). |
yyx990803 commentedApr 9, 2019
•
edited
Before
After
Rendered