what?
v-if 条件渲染
v-if = "表达式"只会在指令的表达式返回真值时才会被渲染。
<script type="module" setup>
import {ref} from 'vue'
let awesome = ref(true)
</script>
<template>
<div>
<h1 v-if="awesome">Vue is awesome!</h1>
<h1 v-else>Oh no 😢</h1>
<button @click="awesome = !awesome">Toggle</button>
</div>
</template>
<style scoped>
</style>
如以上的代码,如果awesome为ture执行,vue is awesome,如果为false执行 oh no。