提交 74c791bd 编写于 作者: D dolymood

feat(form): support union key for v-for

上级 c63fb3df
......@@ -5,7 +5,7 @@
<slot>
<cube-form-item
v-for="(field, index) in fields"
:key="index"
:key="field.key || index"
:field="field"
/>
</slot>
......
<template>
<form ref="form" class="cube-form" :class="formClass" :action="action" @submit="submitHandler" @reset="resetHandler">
<slot>
<cube-form-group v-for="(group, index) in groups" :fields="group.fields" :legend="group.legend" :key="index" />
<cube-form-group
v-for="(group, index) in groups"
:fields="group.fields"
:legend="group.legend"
:key="group.key || index" />
</slot>
</form>
</template>
......@@ -296,12 +300,14 @@
},
addField(fieldComponent) {
this.fields.push(fieldComponent)
this.setValidity(fieldComponent.fieldValue.modelKey)
const modelKey = fieldComponent.fieldValue.modelKey
modelKey && this.setValidity(modelKey)
},
destroyField(fieldComponent) {
const i = this.fields.indexOf(fieldComponent)
this.fields.splice(i, 1)
this.setValidity(fieldComponent.fieldValue.modelKey)
const modelKey = fieldComponent.fieldValue.modelKey
modelKey && this.setValidity(modelKey)
}
},
beforeDestroy() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册