App components do not have access to props directly, but I've discovered some methods that can help pass values to the application.
1. Utilize inject/provide
const app = Vue.createApp({
inject: ['name'],
// ...etc
})
app.provide("name", "Ludwig")
app.mount('#app2')
This is a workaround for passing values (must be done before mounting).
For more details, check out: https://v3.vuejs.org/api/application-api.html#provide
2. Wrap as render function and customize mount
By wrapping in a render function, you can pass props. Customizing your mount function allows for greater flexibility in prop passing.
// App as a component
const appComponent = Vue.defineComponent({
name: "appComponent",
props: {
name: {}
},
// ...etc
})
// Custom mount function
const mountApp = (selector, props) => {
const app = Vue.createApp({
components: { appComponent },
render() {
return Vue.h(appComponent, props)
}
})
app.mount(selector);
}
// Mount with props
mountApp('#app1', {
name: "Darla"
});
Check out this example on JSFiddle