İçeriğe geç

Prop Mutation (ARCH3320)

Anahtar typescript.vue.prop-mutation · Önem error · Kategori quality

Vue: bir prop’a atama yapılmasını işaretler. O değerin sahibi ebeveyndir; çocuğun değişikliği bir sonraki ebeveyn render’ında sessizce ezilir.

<script setup lang="ts">
const props = defineProps<{ count: number }>();
function increment() {
props.count++;
}
</script>
<script setup lang="ts">
const props = defineProps<{ count: number }>();
const emit = defineEmits<{ (e: "update:count", value: number): void }>();
function increment() {
emit("update:count", props.count + 1);
}
</script>