A
A
Anton89892019-03-18 11:37:44
Vue.js
Anton8989, 2019-03-18 11:37:44

What is the correct way to draw output through the for loop of a form field?

Is it possible to output two different form elements at the same time through the v-for directive - input and textarea? For example, as in the picture:

5c8f5840c311b513830255.png

The list itself in the script looks like this:

{
    id: 0,
    title: 'Phone',
    type: 'text'
},
{
    id: 1,
    title: 'Message',
    type: 'textarea'
},

I can’t figure out what property to specify here so that after the loop is completed, the input is displayed first, and then the textarea.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
andrei_pro, 2019-03-18
@Anton8989

I think you need to do this:

<div v-for="element in emelents">
   <div v-if="element.type === 'text'">
      <input />
   </div>
   <div v-if="element.type === 'textarea'">
      <textarea><textarea/>
   </div>
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question