i need a help for some v-model and v-for error , i can't set the value of radio buton , and i can't pass the value of radio buton ( who is get in my backend )
The error is :
"'v-model' directives cannot update the iteration variable 'etat_commande' itself"
I used vuejs3
here is my code :
<div
v-for="etat_commande in etat_commandes"
:key="etat_commande.code"
>
<input type="radio"
:value="etat_commande.code"
v-model="etat_commande"
:disabled="!canWrite('etat_commande')"
@change="onChange('etat_commande')"
name="radio">
{{ etat_commande.label }}
</div>
<script>
export default {
data() {
return {
etat_commandes: [],
}
},
}
computed: {
etat_commande:{
set(code) {
console.log("etat_commande.code", code);
if(code !== "") {
this.articleStore.article.etat_commande = { code };
} else {
this.articleStore.article.etat_commande = null;
}
},
get() {
const code = this.articleStore.article?.etat_commande?.code;
return code != null && code != undefined ? String(code) : "";
}
},
}
</script>