M
M
Morfeey2018-05-08 15:37:26
Vue.js
Morfeey, 2018-05-08 15:37:26

Why the same instance?

I’ll say right away that I’m sitting on vue right at the very beginning, if you throw a stone, throw it together with an example of “how it should be”.
So, there is a small page on which the json listing of the available logs is displayed in the first section. The listing contains the necessary information for further "poking" through it and opening the current log in the next section. This is done in the following way:
5PRyCvAfE-U.jpg
The function with the second instance is the "piercing" of the required item in the listing.
The problem is that after the first poke, a new log does not want to be rendered, it seems to be loading, but the page renders "pervak".

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-05-08
@Morfeey

The problem is that after the first poke, a new log does not want to be rendered, it seems to be loading, but the page renders "pervak".

Doesn't it bother you that every time you call ItemBlockClick you create more and more Vue instances using the same element? The new instance uses the rendering result of the previous one as a template - it's bare html, there are no longer any vue directives. So the existing contents of the root element are simply re-created one by one.
Do this: let the second instance of Vue be created initially, and in ItemBlockClick pass new data to it. Or (which would be more desirable) try rewriting your code so that the same vue instance controls the rendering of both sections.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question