我正在尝试将字段添加到 element-ui 表单,并至少需要 2 个字段,并且能够添加更多字段并删除添加的额外字段。以下代码用于我只需要添加字段的表单部分,完整的表单更大并且代码更多。
这是表格代码
<el-form>
<el-row>
<el-col :span="22">
<h4>Options</h4>
</el-col>
<el-col :span="2">
<div class="btn-link-plus action-button">
<i class="fas fa-plus"></i>
</div>
</el-col>
</el-row>
<el-row>
<el-col :span="22">
<el-form-item prop="option">
<el-input v-model="options"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="22">
<el-form-item>
<el-input v-model="options"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
我目前拥有的是出现在我想要添加字段的表单,最初出现的这两个字段应该是必需的。加号按钮应添加一个新字段及其旁边的删除按钮。如下
<el-row>
<el-col :span="22">
<el-form-item>
<el-input v-model="options"></el-input>
</el-form-item>
</el-col>
<el-col :span="2">
<div class="btn-link-delete action-button">
<i class="fas fa-trash-alt"></i>
</div>
</el-col>
</el-row>
How it works is that I'm creating a question and when the response type is selected as multiple choice then this section of the form will appear and the person has to add which are the options available for the answer, with two options being required always以及添加更多和删除添加的能力。
目前,当我写入它写入的任何字段输入时,带有选项的这个数组将保存到与表单的其余部分不同的表中。任何帮助,将不胜感激。