Answer the question
In order to leave comments, you need to log in
How to properly make a dynamic v-model in Vue?
On the person's profile page, I need to parse the JSON coming from the back to his data card (+ highlight the data for which the messages came) and separately display the dynamic number of inputs for those fields where 'type': 'ERROR': 1) with v-model initially equal to the corresponding value from the data object, 2) show the human field name next to it, and 3) the value of the message.
I managed to display the data, but when I started writing inputs: 1) I get a crutch on a crutch, 2) I got to "v-model is initially equal to the corresponding value from the data object" and I don’t understand how to do it, 3) help :o
The Element-UI library is also used, but if you are not familiar with it, everything seems to be intuitive here
{
'status': 'OK',
'messages': [
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'tin_number',
'value': 'Number incorrect'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'documents.guid12345.number',
'value': 'Selfie is incorrect'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'date_of_birth',
'code': 'sfddsf',
'value': 'Selfie is incorrect'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'last_name',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'place_of_birth',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'source_of_funds',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'nationality',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'addresses.ohUhNk-g-Kz3XoAAj-3.address_type',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'addresses.ohUhNk-g-Kz3XoAAj-3.street',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'addresses.ohUhNk-g-Kz3XoAAj-3.house',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'addresses.ohUhNk-g-Kz3XoAAj-3.barangay',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'addresses.ohUhNk-g-Kz3XoAAj-3.zip_code',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'addresses.ohUhNk-h-vjgjaQx7-3.address_type',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'addresses.ohUhNk-h-vjgjaQx7-3.country',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'addresses.ohUhNk-h-vjgjaQx7-3.province',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'addresses.ohUhNk-h-vjgjaQx7-3.municipality',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'addresses.ohUhNk-h-vjgjaQx7-3.street',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'addresses.ohUhNk-h-vjgjaQx7-3.house',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'addresses.ohUhNk-h-vjgjaQx7-3.barangay',
'value': 'PROCESS'
},
{
'type': 'ERROR',
'context': 'FIELD',
'path': 'addresses.ohUhNk-h-vjgjaQx7-3.zip_code',
'value': 'PROCESS'
}
],
'data': [
{
'verification_status': 'NEED_ADDITIONAL_INFO',
'first_name': 'MikS',
'middle_name': 'Val',
'last_name': 'Nokia',
'phone': '639305236773',
'email': '[email protected]',
'date_of_birth': '1988-05-30',
'place_of_birth': 'Ekb',
'gender': 'MALE',
'source_of_funds_id': 10,
'source_of_funds': 'Others',
'nationality_id': 171,
'nationality': 'Philippines',
'addresses': [
{
'guid': 'guid3',
'country_id': 170,
'country': 'Peru',
'province_id': 15,
'province': 'CORDILLERA ADMINISTRATIVE REGION (CAR)',
'municipality_id': 119,
'municipality': 'PAGUDPUD',
'barangay_id': 2100,
'barangay': 'Laoa',
'street': 'fdgashgf',
'house': 'House22',
'zip_code': '2902',
'address_type': 'PRESENT'
},
{
'guid': 'ohUhNk-g-Kz3XoAAj-3',
'country_id': 171,
'country': 'Philippines',
'province_id': 13,
'province': 'REGION XII (SOCCSKSARGEN)',
'municipality_id': 118,
'municipality': 'NUEVA ERA',
'barangay_id': 2201,
'barangay': 'Santo Tomas',
'street': 'SomeStreet',
'house': 'House100',
'zip_code': '2905',
'address_type': 'PRESENT'
},
{
'guid': 'ohUhNk-h-vjgjaQx7-3',
'country_id': 178,
'country': 'Reunion (French)',
'province_id': 13,
'province': 'REGION XII (SOCCSKSARGEN)',
'municipality_id': 118,
'municipality': 'NUEVA ERA',
'barangay_id': 2200,
'barangay': 'Salanap',
'street': 'SomeStreet',
'house': 'House100',
'zip_code': '2905',
'address_type': 'PRESENT'
}
],
'tin_number': '12324-352523',
'documents': [
{
'guid': 'guid12345',
'type_id': 1,
'number': '1234-5466',
'expired_at': '2020-10-23'
},
{
'guid': 'guid1234567',
'type_id': 2,
'number': '1257-6424',
'expired_at': '2019-08-23'
}
],
'photos': [
{
'guid': 'guid123',
'type': 'SIGNATURE'
}
]
}
]
}
Answer the question
In order to leave comments, you need to log in
got to "v-model is initially equal to the corresponding value from the data object" and I don't understand how to do it
<el-form-item v-for="n in formItems">
<el-input v-model="n.value" />
<el-form-item v-for="n in formItems">
<el-input v-model="n.obj[n.key]" />
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question