P
P
Pavel Kleshnin2020-01-09 19:40:10
Vue.js
Pavel Kleshnin, 2020-01-09 19:40:10

How to insert raw html + vue component + raw html ... into a page?

The problem is this:
There is a line containing page markup, you need to prereplace all tags with vue components.
I parsed the string with a regular expression and inserted it into the template in a loop using v-html:

<div v-for="item in arr">
  <кусок до/после pre>
 <!-- Например, в первой итерации <table><tr><td>,
 а во второй </td><td>, и так далее -->
  <компонент вместо pre>
</div>

But in this way (as far as I understand) it first renders <кусок до pre>, then <компонент вместо pre>, automatically closing unclosed tags (which should be closed in the next iteration of the loop), which should contain a new component. in particular, there are replacements inside table cells - the output is a table with one cell, and after it, one by one, the inserted components follow.
I'm not asking for a ready-made solution, but only a hint of what I'm doing wrong and in which direction to dig.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-01-10
@UPSA

v-for and template tag
https://ru.vuejs.org/v2/guide/list.html
template you use as loop boundaries

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question