W
W
whowho2019-04-22 14:01:17
Vue.js
whowho, 2019-04-22 14:01:17

How to dynamically add asynchronous component to dom?

There is such an asynchronous component:

Vue.component(
        'test-component',
        () => import(/* webpackChunkName: "vue-test-form" */ './templates/VueTestForm/TestComponent.vue')
    );

How can it be dynamically added to the dom?
A non-async component can be added using the $mount function. But how to use it for an asynchronous component, I could not understand.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ihor Bratukh, 2019-04-22
@BRAGA96

It's not an async component, just lazy loading it .

import TestComponent from './templates/VueTestForm/TestComponent.vue'

Vue.component('test-component', TestComponent)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question