Files
Vue_Notebook/3.22作业/Vue3Proj/vue-project/src/Com3_3.vue
2025-03-24 14:11:48 +08:00

16 lines
426 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<h3 v-if="flag">条件为{{flag}}渲染这是v-if</h3>
<h3 v-show="flag">条件为{{flag}}渲染h3-这是v-show</h3>
<div v-show="flag" class="div1">div</div>
<button type="button" @click="change">切换元素-{{flag}}</button>
</template>
<script setup lang="ts">
import {ref } from "vue";
const flag = ref(true)
const change = ()=>{
flag.value = !flag.value
}
</script>