Answer the question
In order to leave comments, you need to log in
How to insert a dynamic Vue component into the DOM that is in the html received by xhr?
Hello!
Help, please, deal with the issue.
Given: vue, laravel, webpack.
In resources/js/components are *.vue
components in app.js components are connected dynamically:
const ReviewComponent = () => import(/* webpackChunkName: "review-component" */ './components/ReviewComponent.vue');
const app = new Vue({
el: '#app',
components: {
ReviewComponent
}
});
<div> ... <review-component></review-component> ... </div>
Answer the question
In order to leave comments, you need to log in
Correct answer: don't load html from the server. Seriously, this goes against the very idea of a SPA. Data should be sent from the server, at least something like this:
{
infoBlock: [{
type: 'text',
value: '...'
},{
type: 'component',
value: 'review'
},{
type: 'text',
value: '...'
}]
}
and already SPA will decompose it all into ready-made markup. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question