Problem:
Existing parameters
It needs to be dynamically rendered into the form.
The v-model value problem of each attribute of the form.
定义form对象
searchForm {
sendCode:'',
newHoseFlag:'',
beginEndDate:''
}
template中直接 v-model= 'searchForm[item.field]'
But how to define v-model if there are two objects in each time object?
for example:
searchForm {
sendCode:'',
newHoseFlag:'',
beginDate:{
begainDate:'',endDate:''},
StartDate:{
startDate:'',endDate:''},
metatDate:{
metatDate:'',metaEndDate:''},
}
template为
<el-form-item :label="item.name" :prop="item.field">
<el-date-picker
v-model="???"
type="date"
placeholder="开始日期">
</el-date-picker>
<el-date-picker
v-model="???"
type="date"
placeholder="结束日期">
</el-date-picker>
</el-form-otem>
循环渲染,可通过以下方式定义。
v-model ="searchForm [item.field][object.keys(searchForm[item.field])[0]]"
v-model ="searchForm [item.field][object.keys(searchForm[item.field])[1]]"
``