Aller au contenu

Prop Mutation (ARCH3320)

Ce contenu n’est pas encore disponible dans votre langue.

Key typescript.vue.prop-mutation · Severity error · Category quality

Vue: flags an assignment to a prop. The parent owns that value - the child’s change is silently overwritten on the next parent render.

<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>