Answer the question
In order to leave comments, you need to log in
What is the correct way to generate chunks of raw HTML within a vue framework with access to other vue components?
A list of values in reactive variables is generated. Each of the values can be wrapped in HTML code, which can contain calls to other vue components.
How is it generally right to do it? Is there a best practice?
Ideally, generate HTML through JS, insert using vue through reactive variables. Here you need to understand how to correctly access the vue function through raw js. I read the docs until I understood. This is the crux of the matter.
A more redundant option is to fence some templates of vue itself, but I would not want to do that.
Answer the question
In order to leave comments, you need to log in
So far I don't see any problem. It seems that you just need to deal with templates and components :
Here is the component FooSearchComponent
to which we pass the reactive property via props from the parent foo
:
Vue.component(
"FooSearchComponent",
{
props: ['foo'],
template: '<div>
<a
href="#"
@click="searchFoo(foo)"
>
{{ foo }}
</a>
</div>',
methods: {
searchFoo: function(search) {
console.log("searchFoo:", search);
},
}
}
);
searchFoo()
in which the property is passed as a parameter (reactive, from outside)foo
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question