0

I have a form with three input fields name, email and phone but I want the user to be able to add more input fields dynamically so for every new input field added to the form, I want to declare a variable in the form object of data function.

The data() function is as below:

data(){
    return{
        form:{
            name:'',
            email:'',
            phone: '',
        }
    }
}  

Here as you can see I have three variables in the form object but I want to dynamically add another variable like phone2, phone3...etc. whenever a new input field is added dynamically to the form.

Any help is appreciated in advance.

1

1 Answer 1

0

for your question is the full answer by @Dan. But why are you don't want to create a phone array to store dynamic phones in it? You can easily work with array add\remove and etc...

data(){
return{
    form:{
        name:'',
        email:'',
        phone: [XXXXXXX, XXXXXX],
    }
}

}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.