S
S
SWFaust2017-03-26 20:24:16
JavaScript
SWFaust, 2017-03-26 20:24:16

Vue2 How to get template result into variable?

I recently started learning Vue2.
I can't figure out how to get the render result of a component into a variable in vue. In the documentation and in all the examples, the components immediately change the html.
The essence of the problem.
Installed a plugin for notifications https://github.com/shakee93/vue-toasted
It accepts notifications in text or html. Everything is good, everything is fine.
But I plan to have 10 notifications different in appearance with a completely different layout.
Actually wanted to make components for them. And their result is already transferred to the plugin. But I still haven’t figured out how to call a component in js with passing incoming parameters to it and get html into a variable.
In fact, use it as a lodash template.
Of course, you can not bother and use _.template, but somehow it seems prettier through the components.
Does anyone know how to do this with vue?
And another question, is it worth it? Wouldn't that be using the microprocessor as a hammer, i.e. won't this have a negative impact on performance compared to the same lodash _.template?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bogdan Dukhevich, 2017-03-30
@SWFaust

With a completely different layout? Just completely different? If so, then create a separate class via Vue.extend (which will describe the common things that bind all these components) and then use it to create components with different templates.
And somehow I don’t see the point of rendering the component to a string using VueJS.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question