Cristiano Magro
2024-12-30 05275d80c65c82fd9be1e7137af8514aff9dbbc2
07 - development setup/cmp-communication-assignment-problem/src/components/UserData.vue
@@ -1,37 +1,36 @@
<template>
    <form @submit.prevent="submitData">
    <div>
        <label>Utente: </label>
        <input type="text" v-model="username">
    </div>
    <div>
        <label>Eta: </label>
        <input type="text" v-model="age">
    </div>
    <div>
        <button>Update</button>
    </div>
</form>
        <div>
            <label>Utente: </label>
            <input type="text" v-model="username">
        </div>
        <div>
            <label>Eta: </label>
            <input type="text" v-model="age">
        </div>
        <div>
            <button>Update</button>
        </div>
    </form>
</template>
<script>
export default {
    data(){
    data() {
        return {
            username: "",
            age: "",
        }
    },
    emits: ['update-user'],
    methods:{
    methods: {
        submitData() {
            if(this.username !== "" && this.age !== ""){
            this.$emit('update-user', this.username, this.age);
            if (this.username !== "" && this.age !== "") {
                this.$emit('update-user', this.username, this.age);
            } else {
                alert("insert data")
            }
                alert("insert data");
            }
        }
    }