-
Notifications
You must be signed in to change notification settings - Fork 263
Open
Description
In "emit to parent" feature for Vue 3, the code can be simplified to the following:
App.vue
<script setup>
import { ref } from "vue";
import AnswerButton from "./AnswerButton.vue";
const isHappy = ref(true);
</script>
<template>
<p>Are you happy?</p>
<AnswerButton v-model="isHappy" />
<p style="font-size: 50px">
{{ isHappy ? "😀" : "😥" }}
</p>
</template>AnswerButton.vue
<script setup>
const isHappyModel = defineModel({ type: Boolean });
</script>
<template>
<button @click="isHappyModel = true">YES</button>
<button @click="isHappyModel = false">NO</button>
</template>I understand that the point is to demonstrate Vue's syntax and feature in this specific scenario, but you should either change the example to a more practical one in which defineModel() isn't enough, or mention this feature below the current example.
Metadata
Metadata
Assignees
Labels
No labels