Home >Web Front-end >Front-end Q&A >What are the logical judges of Vue?

What are the logical judges of Vue?

青灯夜游
青灯夜游Original
2021-12-22 18:57:205863browse

There are three types of logical judgment operators in vue: 1. Logical AND operator "&&", which returns true only when both operands are true, otherwise it returns false; 2. Logical OR operator "||", if one of the two operands is true, it returns true; 3. The logical NOT operator "!" performs a negation operation.

What are the logical judges of Vue?

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

Logical operators in vue

  • && and, if false, AND is false

  • || Or, there is true or is true

  • ! Not, negate

We can be in the same v-if Use them in instructions, such as

  • && = logical operator AND; only when both operands are true, it returns true, otherwise it returns false.

  • || = Logical operator OR; if both operands are true, or one of them is true, return true, otherwise return false.

&& means that the div to be displayed must meet two conditions;

<div class="o-overlay" v-if="show && visible">
    <div class="o-overlay__bg" @click="hide"></div>
</div>

|| means that only one condition must be met It can only be displayed if it is div.

<div class="o-overlay" v-if="show || visible">
    <div class="o-overlay__bg" @click="hide"></div>
</div>

[Related recommendations: "vue.js tutorial"]

The above is the detailed content of What are the logical judges of Vue?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn