如何在v-for循环中的vuejs中采用动态v-model

时间:2020-08-27 17:17:12

标签: javascript laravel vue.js

我正在使用v-form。我试图动态地在v-for循环中获取一些输入字段。这是我的代码

<div class="row attribute-fields">
                                    <div class="col-md-4 col-sm-12 col-lg-4" v-for="(singleAttribute,index) in attributes"
                                         :key="index">
                                        <div class="form-group">
                                            <label for="attribute_name">{{ singleAttribute.attribute_name }}</label>
                                            <input type="text" class="form-control" id="attribute_name"
                                                   :placeholder="singleAttribute.placeholder" v-model="form.attribute[index]">
                                        </div>
                                    </div>
                                </div>

此属性在更改“ selectLIst”后出现。确定,可以给我答复。但是我在v模型中出错。像这样 enter image description here

数据属性中的 在这样初始化我的变量中

form: new Form({
                id: '',
                category_id: '',
                subcategory_id: '',
                child_category_id:
                 attribute: [],
            })

现在我想使用其索引号将所有输入值保存在varibale属性中。喜欢

form.attribute[1] = 'value';

请帮我解决这个问题

0 个答案:

没有答案