volatile size form
-
I have:
<div class="flex row" v-for="(value, name) in form" :key="name"> <q-input class="col q-mr-sm" filled dense /> <q-input class="col" filled dense /> </div> <q-btn color="primary" icon="post_add" class="q-mb-md" label="Add field" />
form: { field1: 'value1', field2: 'value1' }
I want to set field/value, maybe with v-model, but I don’t know how… someone can help?
-
So, with what you have, you don’t need a v-for.
If you want to use a v-for, you’d probably want each field’s v-model (and any other data for the field) to be in its own object and then have an array of field objects.
Try putting a codepen together to get as far as you can and we can collaborate on that.
Scott
-
@zeppelinexpress
v-model="form[name]"
, https://codepen.io/metalsadman/pen/XWNeyoV?editors=101 -
thanks guys!, @metalsadman and if I want a button to add fields as needed?
-
@zeppelinexpress wouldn’t matter, as long as the properties are unique, otherwise just go for an array.
-
thanks, I did in an ugly way, but at least it’s working