0

I have an Vue app with this data:

data: {
    personal: {
        email: '',
        first_name: '',
        last_name: '',
        password: '',
        password_confirmation: '',
        phone: '',
        work_email: ''
    },
    company: {
        address: '',
        annual_revenue: null,
        city_id: null,
        country: 'BRA',
        company: '',
        company_city_document: '',
        company_document: '',
        company_legal_name: '',
        position: '',
        state_id: null,
        vat: null,
        website: '',
        work_phone: '',
        zipcode: ''
    }
}

I want to acess the child object from my mixin, but when i send the propertie via param i get undefined on mixin, im sending like this:

<TextField
    @input="checkFormInvalidity('personal.first_name')"
    id="first_name"
    label="Nome"
/>

When user types anything vue will emit what he typed, in my mixin is a simple verifying method like this:

checkFormInvalidity (field) {
    field
        ? this.$v.data[field].$touch()
        : this.$v.$touch()

    return field
        ? !!this.$v.data[field].$invalid
        : !!this.$v.$invalid
}

When i do:

console.log(this.data[field])

I receive "undefined" because i don't know how to access the child object from data in that case would be "data.personal.first_name". If i receive in param "field" only "personal" i can see all data properties.

Igoohd
  • 136
  • 7

0 Answers0