Skip to content Skip to sidebar Skip to footer

Why Dynamically Mounted Vuejs Content Is Not Child Component Of Root Vue Instance?

I load some html containing customized component, and mount that content to a fixed node in parent component. Unfortunately, i found there is no parent-child relationship between t

Solution 1:

Normally when you create dynamically a Vue component is not child of any particular instance. You can set the parent explicitly within the options

var _this = thisvar child = newvmtemp({parent:_this}).$mount(document.getElementById('dynamicloaded'))

Inside your addNewElement function.

Let me know if it works for you.

Solution 2:

thanks to the vuejs creator's help, i have tried async component approach, it really works and right parent-child relationship setup when after dynamic content rendered into dom. https://github.com/vuejs/vue/issues/3255#issuecomment-231686976

Post a Comment for "Why Dynamically Mounted Vuejs Content Is Not Child Component Of Root Vue Instance?"