0
votes

I am working with vue and here is my code

everything is working fine until I submitting the form. when I submit form and try to update emailForm -> tabs -> en -> data -> name then i got an error.

<template>
    <el-form :model="emailForm.tabs" ref="emailForm" class="demo-emailForm" @submit="submitForm('emailForm')">
        <div v-for="(lan, key, index) in emailForm.tabs">
        <el-form-item :label="$t('Template Name')" >
            {{lan.data.name}}
       </el-form-item>
    <el-form>
<template>
<script>
        export default {
            data() {
                return {
                    emailForm: {
                        tabs: {
                            en: {
                                sortHeand: 'en',
                                title: 'English',
                                data: {
                                    name: "ad",
                                    subject: "asda",
                                    html_code: 'asdad',
                                    status: 0
                                }
                            }
                        }
                    }
                }
            },
            methods: {
                submitForm(formName) {
                    this.$refs[formName].validate(valid => {
                        if (valid) {
                            request({
                                url: this.getRoute(),
                                method: "post",
                                data: this[formName].tabs
                            })
                            .then(response => {
                                console.log(response)
                            })
                        }
                    });
                },
            }
        }
</script>

Anyone can render this issue ?

enter image description here

1
Are you sure you provided correct code? Your methods is inside of data()dziraf
You definitely missing a } jsfiddle.net/Jubels/eywraw8t/374456Jeremy Walters
Yes that was my mistake let me edit this..., in my my side it's perfectParth Jasani

1 Answers

2
votes

You're trying to read property name from variable/object data but data is undefined so it can't read the property name from it.