A
A
alex2018-08-23 12:09:53
Vue.js
alex, 2018-08-23 12:09:53

Dynamic loading and rendering of a component?

It is necessary, depending on the conditions, to load and render two components.
I'm trying like this:

new Vue({
  router,
  store,
  async render: h => isMobile ? h(await import('@/AppMobile.vue')) : h(await import('@/App.vue'))
}).$mount('#app')

Can you tell me what I'm doing wrong, or is there an easier way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-08-23
@potapchino

new Vue({
  router,
  store,
  components: {
    AppModile: () => import('@/AppMobile.vue'),
    App: () => import('@/App.vue')
  },
  render: h => h(isMobile ? 'AppMobile' : 'App')
}).$mount('#app')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question