こんな感じで、ref属性にアクセスして反転させれば良いだけ。 反転したのをvalueに入れる。 ifの下した認識されないのがルール
<script setup> import { ref } from 'vue' const awesome = ref(true) function toggle() { awesome.value = !awesome.value } </script> <template> <button @click="toggle">toggle</button> <h1 v-if="awesome">Vue is awesome!</h1> <h1 v-else>Oh no 😢</h1> </template>
野良にいいのがない場合は公式が早いかも
公式いっぱい調べた方が良いのかなー