A
A
Alexander Savenko2018-07-11 23:20:35
Vue.js
Alexander Savenko, 2018-07-11 23:20:35

How to preserve element order in Vue when applying v-if?

Hello!
There is such code and sometimes you need to hide some tabs:

<ul>
<li>1</li>
<li v-if="isVisible">2</li>
<li>3</li>
<ul>

I change to isVisible= false and back to true and the order changes (((
<ul>
<li>1</li>
<li>3</li>
<li v-if="isVisible">2</li>
<ul>

How to avoid it? I tried :key to specify and does not help (((

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2018-07-11
@0xD34F Vue.js

I change to isVisible= false and back to true and the order changes

Yes, well ? You are clearly missing something.

A
Alexander Savenko, 2018-07-13
@savenko

It turned out that the matter was in the uiv and Tabs component. Rewrote the component and everything worked as it should

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question