2.8.1. Conditional judgment

v-if

The conditional judgment uses the v-if instruction, and the expression of the instruction will only be displayed when it returns true :

v-if instruction

Use in an element v-if directive:

<divid="app"><pv-if="seen">Now you see mep>div><script>const app = { data() { return { seen: true /\* Change to false, the information cannot be displayed \*/ } } } Vue.createApp(app).mount('#app')script>    

Here, the v-if instruction will determine whether to insert the p element based on the value of the expression seen ( true or false ).

Because v-if is an instruction, it must be added to an element. If there are multiple elements, they can be wrapped around the