M
M
Mors Clamor2021-03-25 19:52:28
1C-Bitrix
Mors Clamor, 2021-03-25 19:52:28

Why doesn't the condition work on Vue?

Hello! Today I spent the whole day tinkering with a problem: there is a task to draw a drop-down menu for elements of a certain category of goods (site on Bitrix). On the Vue front, it's all bundled with Webpack. From Bitrix, I get the GUID of the section from the infoblock, and if I see the desired section, I throw the flag to the front, for example (show_times = N or show_times = false), depending on what the menu will be drawn or not. Here is the drawing code

<div id="root">
<div class="какой-то блок" v-for="serv is Services">
<select v-if="((serv.times.length > 1) && (serv.show_times === 'Y'))">
<!--Тут какие-то options-->
</select>
</div>
</div>


The code is conditional, but I conveyed the essence exactly. I inherited the project, the condition with serv.times.length was there initially and worked successfully, I just added the second condition. For debugging, I wrote a vue loop, where it displayed each object (well, it is converted to json there) and the show_times field successfully arrives both as a string and as a boolean. However, the condition does not want to be processed in any way, I even broke it and displayed the result of each comparison, it considers everything correct, but if the value is false, the entire expression is still drawn. Everything works correctly if you manually set && show_times to false, then it does not render. Could it be some peculiarities of working with Vue variables, maybe I'm doing something wrong, some Webpack tricks or caching? I already cleared all the caches 10 times,

Summary: a variable comes to Vue, I can read it successfully, but the condition using it does not work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Gritsuk, 2021-03-26
@66demon666

try to see what's in Services through the Vue Devtools browser extension. In order for it to work in init.php add define('VUEJS_DEBUG', true);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question